philsturgeon / codeigniter-oauth2 Goto Github PK
View Code? Open in Web Editor NEWNO LONGER ACTIVELY MAINTAINED. USE https://github.com/thephpleague/oauth2-client INSTEAD
Home Page: http://getsparks.org/packages/oauth2/versions/HEAD/show
NO LONGER ACTIVELY MAINTAINED. USE https://github.com/thephpleague/oauth2-client INSTEAD
Home Page: http://getsparks.org/packages/oauth2/versions/HEAD/show
From the main call in the oauth2 class:
$user = $provider->get_user_info($token->access_token);
I have only tested this with Facebook so far but within get_user_info - the initial call with the users access token
$url = 'https://graph.facebook.com/me?'.http_build_query(array(
'access_token' => $token->access_token,
));
Is improperly referencing the token string. Since '$token->access_token' is passed into 'get_user_info' the token is no longer an object but a string.Thus,
$url = 'https://graph.facebook.com/me?'.http_build_query(array(
'access_token' => $token,
));
Allows the token to properly be passed.
Hi gang.
I have a fresh version of CI running and I've installed the codeigniter-oauth2 spark via bash on my Ubuntu instances on EC2.
I followed the directions of the documentation and created a controller called auth using the demo code.
I have looked in my sparks folder and all the correct files/folders are there (as well as the /0.4.0 folder).
I have added the Facebook
My autoloads file has this
$autoload['libraries'] = array('session','OAuth2');
Now when I open the page mydomain.com/auth/sessions/facebook I get the error
"Unable to load the requested class: oauth2"
I can't seem to find any other assistance online regarding this issue online. I don't think it's an issue of not having the right case as I have tried all different ways of writing it.
Any direction to fix this issues would be greatly appreciated.
In your example usage section this line:
$user = $provider->get_user_info($token->access_token);
Should be replaced with this:
$user = $provider->get_user_info($token);
I know it's deprecated but i have a little fix in Facebook provider (Provider/Facebook.php)
Line 28. Change:
$url = 'https://graph.facebook.com/me?'.http_build_query(array(
'access_token' => $token->access_token
));
To this:
$url = 'https://graph.facebook.com/me?'.http_build_query(array(
'access_token' => $token->access_token,
'fields' => 'id,name,email,first_name,last_name'
));
here is my code suggestion that works with windowslive Outh to provide user email and name
FILE - libraries/Provider/Windowslive.php
Code
/* at line 49 the return array */
return array(
'uid' => $user->id,
'name' => $user->name,
'nickname' => url_title($user->name, '_', true),
'first_name' => $user->first_name,
'last_name' => $user->last_name,
'email' => $user->emails,
// 'location' => $user[''], # scope wl.postal_addresses is required
# but won't be implemented by default
'locale' => $user->locale,
'urls' => array('Windows Live' => $user->link),
);
Line 42 in /libraries/Provider/Blooie.php
needs closing breaket (master branch).
I am using the laravel-oauth2 package for Laravel 4 to set up a Facebook login. I am using the package seen here: https://github.com/madewithlove/laravel-oauth2 (which is based on your repository here).
When running the page that controls the login, the public/oauth/facebook, the Facebook prompt comes up fine, but when I click "accept", the page spits out the following error:
ErrorException
Argument 1 passed to OAuth2\Provider\Facebook::get_user_info() must be an instance of OAuth2\Token\Token_Access, instance of OAuth2\Token_Access given, called in /Applications/MAMP/htdocs/crowdsets/laravel-master/app/controllers/Oauth2Controller.php on line 36 and defined
It is pointing to /vendor/taylorotwell/laravel-oauth2/src/OAuth2/Provider/Facebook.php: 26
The get_user_info() function in Facebook.php looks like this:
public function get_user_info(Token_Access $token)
{
$url = 'https://graph.facebook.com/me?'.http_build_query(array(
'access_token' => $token->access_token,
));
$user = json_decode(file_get_contents($url));
// Create a response from the request
return array(
'uid' => $user->id,
'nickname' => $user->username,
'name' => $user->name,
'email' => $user->email,
'location' => $user->hometown->name,
'description' => $user->bio,
'image' => 'https://graph.facebook.com/me/picture?type=normal&access_token='.$token->access_token,
'urls' => array(
'Facebook' => $user->link,
),
);
}
My Oauth2Controller.php file looks like this:
'****************', 'secret' => '********************', )); if(! isset($_GET['code'])) { return $provider->authorize(); } else { // Howzit? try { $params = $provider->access($_GET['code']); $token = new Token_Access(array( 'access_token' => $params->access_token )); $user = $provider->get_user_info($token); // Here you should use this information to A) look for a user B) help a new user sign up with existing data. // If you store it all in a cookie and redirect to a registration page this is crazy-simple. echo ""; var_dump($user); } catch (OAuth2_Exception $e) { show_error('That didnt work: '.$e); } } } ``` } I am not sure why it is given me this error, as I followed the documentation and tutorials. Thank you for your help with solving this issue.
Hi,
I get error when i going to connect linkedin login allow access done. After redirect with access code i got following error message.
An uncaught Exception was encountered
Type: Exception
Message: Required option not passed: access_token
Filename: libraries/Token/Access.php
Line Number: 44
The instagram provider is set with OAuth_Provider_Instagram as the class name, shouldn't this be OAuth2_Provider_Instagram ?
Would love to see one. I'm a total noob to PHP and CodeIgniter (which I wouldn't need to be, if I weren't bootstrapping for my project and had money to hire developers).
I find the stuff a little bit intimidating. The documentation is sparse.
Thank you.
It seems there is no address attribute in $user .
I suggest just 'return $user;' in Paypal.php (line 41).
I just using first time this library, but I have this issue. When I serve the code in Ubuntu it prompts me this error. I have autoloaded libraries.
Fatal error: Class 'OAuth2_Provider' not found in /path-to-libraries/libraries/oauth2/Provider/Facebook.php on line 13
Should I have to consider tu require once?
bests regards
On line 32 when it says:
'nickname' => $user->username,
I think it should be:
'nickname' => $user->nickname,
Since I'm getting an error actually and there is no username on my Facebook response.
Is it possible to make google token persistent so that users don't have to allow the application each time they connect ?
Thanks
The class loads OK but then the class can't load the provider files.
the include in the function class provider (line #28) fails.
OAuth2_Token_Access Object ( [access_token:protected] => 1527925940.ac27022.0b9eec4ea32f4ac788aaec67342ab869 [expires:protected] => [refresh_token:protected] => [uid:protected] => )
Hi
How would I call api using this library in any controller. For example if I want to call get_user_info($token) function from Facebook.php provider using different controller and display it on view. Same with the linkedin I want to show user's connection after they login using OAuth.
Any help would be appreciated
Thanks.
what gives?
I just tried using the Instagram provider to authenticate users in my app and for te most part it works out fine, however when after users grant access to my app and I try to run:
$token = $provider->access($_GET['code']);
I get a 400 Request error, I tried doing the same request via CURL like it says in the Instagram docs:
curl \
-F 'client_id=CLIENT-ID' \
-F 'client_secret=CLIENT-SECRET' \
-F 'grant_type=authorization_code' \
-F 'redirect_uri=YOUR-REDIRECT-URI' \
-F 'code=CODE' \
https://api.instagram.com/oauth/access_token
And it returns the access_token
just fine so could it be a problem in how the POST request is beign handled?
Thanks in advance!
Hi - The following code in the Provider.php constructor obtains the call URL if the parameter is passed in:
isset($options['callback']) and $this->callback = $options['callback'];
However, a few lines later the redirect URL is set to the URL of the page where the user initiated the auth request:
$this->redirect_uri = site_url(get_instance()->uri->uri_string());
That redirect URL is passed to the provider and the callback URL appears never to be used. Replacing the first line I cited with the below seems to solve the issue. Am I right here?
$this->redirect_uri = site_url(get_instance()->uri->uri_string()); //this line must be moved up above if statement from below
if(isset($options['callback']) and $this->callback = $options['callback'])
{
$this->redirect_uri = $this->callback;
}
I just saw this error while integrating oauth2 0.3.1 in my application. Can you please suggest me on this?
On spark install warning presented:
[ WARNING ] Git not found - reverting to archived copy
Hi. is it possible to add yahoo provider?
The error:
Unable to load the requested class: oauth2
with the loader + example in http://getsparks.org/packages/oauth2/versions/HEAD/show
$this->load->spark('oauth2/0.3.0');
Thanks for your helping
I am trying to use oauth2 with Github api but I am keeping having this message
Message: file_get_contents(https://api.github.com/user?access_token=sometokenhiddenhere): failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden
Filename: Provider/Github.php
Line Number: 32
Any idea on how to solve that problem ? I tried cURL to but it is giving an empty array. That said when I copy paste the url on the browser I get all the information
Cheers
this package not have a twitter provider?? please i need to twiiter provider help me,
Hi Phil
Could I user your Oauth2 library for allowing (only) users from a google apps domain to login into my Codeigniter application? I mean, in this case I'd need only 1 provider, right?
Will I need a SSL cert.?
Thanks for any clarification you can give me
Fatal error: Cannot use object of type stdClass as array in libraries\Provider\Paypal.php on line 44
After success login to paypal and go back to the return path I got this error.
~
Hey there, I'm willing to implement refresh token with Google. I've managed to exchange the autorisation token for an access token but can't manage to make it work with refresh token.
From what I see in OAuth 2 provider, the token factory is gonna try to load Token/Refresh.php
which doesn't exists.
Am I taking this the wrong way or is this something codeigniter-oauth2 doesn't supports ?
Would love to see a refresh example if possible.
Thanks a lot !
I've tried to debug the error, but no success for me! Hope you can give me a hand on this issue:
Fatal error: Uncaught exception 'Exception' with message 'Required option not passed: access_token Array ( ) ' in C:\xampp\htdocs\project.com\application\libraries\OAuth2\Token\Access.php:43
Is what I get when I try an session/facebook (Haven't tried any other service)
Authorization endpoint
Old https://identity.x.com/xidentity/resources/authorize
New https://www.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize
Token Service endpoint
Old https://identity.x.com/xidentity/oauthtokenservice
New https://www.paypal.com/webapps/auth/protocol/openidconnect/v1/tokenservice
User profile endpoint
Old https://identity.x.com/xidentity/resources/profile/me
New https://www.paypal.com/webapps/auth/protocol/openidconnect/v1/userinfo
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.