Back

[Package] OAuth - Never been so easy!


This is my first Laravel package and I'm really excited to contribute! :)

The goal of this package is to make OAuth process easier than ever in Laravel applications.

Available Providers

  • Google
  • Facebook
  • Twitter
  • Yahoo!
  • more are coming!

You may choose where to store the retrieved tokens. Several storage drivers are available, the main application driver is used by default.

Available Storage Drivers

  • Redis
  • Memcached
  • APC
  • Database
  • File

You may use API helpers to play with the providers APIs. For the time being, only some Facebook helpers are available

Available API Helpers

Facebook

Package link: https://bitbucket.org/cerbero/oauth

Packagist link: https://packagist.org/packages/cerbero/oauth

cerbero90 replied 5 years ago

Replies to the old forum questions:

First of all thank you for your interest and sorry for the late reply

@zwacky: I deeply edited the documentation, is it more straightforward now?

@mango: thank you for your feedback, I'll check out Yahoo

cerbero90 replied 5 years ago

Yahoo! provider added as requested and main post updated

jgarifuna replied 5 years ago

Thanks for sharing, cerbero90!

I know first hand how time-consuming it is to implement these types of integration, so your contribution is greatly appreciated.

riggscastro replied 5 years ago

keep it up, this will be a big help for us newbies!

cerbero90 replied 5 years ago

@jgarifuna: you're very welcome :) I can work on it only in weekends, this is why I release weekly updates

@riggscastro: thanks, I'm glad you find this package useful :)

cerbero90 replied 5 years ago

Added Facebook API helpers to manage Applications. Main post updated

cerbero90 replied 5 years ago

Added Facebook API helpers to manage Checkins and Comments. Main post updated

karev replied 5 years ago

awsome cerbero90 keep the good job

cerbero90 replied 5 years ago

thanks karev :)

If somebody needs a specific implementation of OAuth providers or API helpers, please let me know

ArcticZero replied 5 years ago

Hey cerebro90, great package! Was completely frustrated when I realized Anvard wasn't in development anymore, and using HybridAuth itself didn't feel very well integrated with Laravel. A few questions:

  • How do I save retrieved information (e.g. email, first/last name) to the database?
  • What specific fields/tables I have to add to my database?

Again, thank you for this package! :)

cerbero90 replied 5 years ago

Hi ArcticZero :) you can be very flexible about it and don't need specific fields or tables to store user information.

The package offers simple methods to gather the data you need, then you can store them wherever you want.

For example:

$id = Facebook::id();
$email = Facebook::email();

$user = Auth::user();
$user->fb_id = $id;
$user->email = $email;
$user->save();
cerbero90 replied 5 years ago

Added API helpers for events on Facebook. Main post updated

felipepodesta replied 5 years ago

Nice package.

emerson5 replied 5 years ago

If you want to allow login from multiple providers, is there a simple way to have a different redirect_uri for each provider, or some way to detect in your redirect function which provider the redirect came from? By the way, great package, thanks a lot!

emerson5 replied 5 years ago

Is there any documentation for this package other than what's on the bitbucket wiki? If not, I would suggest adding the following: For Facebook, you can run the functions in the PHP SDK by chaining them on Facebook::client(). For example, to run the function getUserAccessToken in the SDK, you would do:

Facebook::client()->getAccessToken();

Also, when making API calls, you might want to check for an expired access token. I think that the only way to do this is to make an API call and see if you get back an OAuthException. Something like this:

try
{
    $fb_email = Facebook::email();    
    $fb_id = Facebook::id();
}
catch(Exception $e)
{
    return Redirect::to(Facebook::request('email'));
}

Also, might be good to put this in your logout function:

Facebook::client()->destroySession();
cerbero90 replied 5 years ago

Sorry for the lack of updates, I'm very busy in this period.

@emerson5 you can find the route you're looking for in Cerbero / Oauth / routes.php For the time being, if you want to add more logic to it, feel free to copy & edit it. I'm going to fire an event with the next update.

You may call client() with every provider, that allows you to be more flexible, thank you for your suggestions, I will update the package and documentation as soon as possible :)

kensim86 replied 4 years ago

hello,

thank you for the excellent package :) however, I am wondering, from the quick example,

$google = Google::request('email');

could I ask for calendar permissions from here as well? like

$google = Google::request('email','calendar');

and for

    $id = Google::id();
    $email = Google::email();

May I know other than id and email, where can I find the other methods that I can use as well? For example could I get the profile picture?

Thanks!

cerbero90 replied 4 years ago

Hi kensim86,

sure you can :) have a look at https://developers.google.com/google-apps/calendar/auth to find out what are the scopes.

id() and email() are just shortcuts, you may access every client method via Google::client()->method(); This is the Google client: https://github.com/google/google-api-php-client/blob/master/src/Google/Client.php

emerson5 replied 4 years ago

I'm running into an error in my application that includes this package when deployed to Heroku:

Class 'Cerbero\Oauth\Oauth' not found

It works fine in my local environment, and when I remove this package, everything in the rest of my application works. It's pretty tough to troubleshoot, because I can't repeat the error locally. I've tried running artisan dump-autoload and artisan optimize in the heroku shell after deploying, but I still get that error. Has anyone else run into this? Any ideas?

sterlingsolutions replied 4 years ago

I'm having the same problem as emerson5, works locally but will not work live (Fortrabbit), same exception:

Class 'Cerbero\Oauth\Oauth' not found

Anyone have a solution for this?

thiagovictorino replied 4 years ago

Hi

I try to run the composer, but I have this error

Package facebook/php-sdk is abandoned, you should avoid using it. Use facebook/php-sdk-v4 instead.

And I can't to use this package.

mocheaz replied 4 years ago

How can i destroy Google session?


Sign in to participate in this thread!



We'd like to thank these amazing companies for supporting us