oauth-io / sdk-php Goto Github PK
View Code? Open in Web Editor NEWOAuth that just works ! This is the PHP SDK for OAuth.io
Home Page: https://oauth.io
OAuth that just works ! This is the PHP SDK for OAuth.io
Home Page: https://oauth.io
After the redirect at this step:
´´´
$request_object = $oauth->auth('the_provider', array(
'redirect' => true
));
´´´
I get error messages and in investigations I traced the problem to src/OAuth_io/OAuth.php
line 148:
$code = $data['data']['code'];
When I dump the parsed JSON there is no field code
, but there is access_token
. Did the returned encoded JSON change? I also tried just setting $code
to access_token to verify, but ran into other complications, so I am asking the maintainers here for more informed input.
Hi, I love the complete oauth solution provided with oauth.io, oauthd and the various libraries. For a specific application I require the ability to have a custom value for "state" in the json payload. Now it contains a random string generated by this method:
public function generateStateToken()
Would it be an idea to add the ability to customise this somehow? Of course I can easily extend the class myself but I can imagine others could use this functionality as well?
I have integrated the phonegap sdk and the php server sdk in my application.
I have managed to get to the point, where I can call the me()
method of the request_object
.
I would like to retrieve to refresh_token, but I can't find a way to do that. What's the supposed way to do that in PHP?
$request_object = $this->oauth->auth('google');
$me = $request_object->me();
Log::debug($me);
We are trying to write an authantication module for our Drupal 8 website. We are using oAuth.io for external authantications (with social media platforms) every other platform works perfectly. But when we try to login with Twitch we get the error:
Notice: Trying to get property of non-object in OAuth_io\RequestObject->me() (line 133 of [root]/vendor/oauth-io/oauth/src/OAuth_io/RequestObject.php)
This is the code in our redirect page:
$oauth = new OAuth();
$oauth->initialize(['oauthApiKey'], ['oauthSecretKey']);
$request_object = $oauth->auth($provider, [
'redirect' => true
]);
$socialDataArray = $request_object->me('email'); [or ->me() -both the same]
This is very urgent. Could you please help?
This is the auth method in src/OAuth_io/OAuth.php. The screenshot is the relevant section of code from the oauthd server. Any help would be greatly appreciated!
AUTH - RESPONSE PRINT_R = Unirest\HttpResponse Object( [code:Unirest\HttpResponse:private] => 400 [raw_body:Unirest\HttpResponse:private] => Missing origin or referer. code: InvalidHeader message: Missing origin or referer. [body:Unirest\HttpResponse:private] => Missing origin or referer. code: InvalidHeader message: Missing origin or referer. [headers:Unirest\HttpResponse:private] => Array ( [Content-Type] => text/html; charset=utf-8 [Content-Length] => 157 [Date] => Wed, 30 Jul 2014 15:31:19 GMT [Connection] => keep-alive ))
I'm using the PHP-SDK of oauth.io. I get the following error:
[2015-02-04 11:35:35] local.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Class 'Unirest' not found' in /home/vagrant/Code/shelfflip-web/vendor/oauth-io/oauth/src/OAuth_io/HttpWrapper.php:33
Stack trace:
#0 [internal function]: Illuminate\Exception\Handler->handleShutdown()
this is my composer file:
"require": {
"laravel/framework": "4.2.*",
"mashape/unirest-php": "dev-master",
"oauth-io/oauth": "0.3.0"
},
After inspecting the architecture of this module I feel a rewrite is in order. I've begun this work here: https://github.com/TomHAnderson/sdk-php/tree/rewrite
The client isn't unit tested or functionally tested but the general shape of the class is coming into view. Rather than an injector pattern this rewrite uses a factory pattern with getters and setters for all options so if what you get from the factory isn't what you need you can set all configurable options manually with setters.
One change stood out in particular: The session use would namespace the app into a [oauthio] namespace. But the code was coded to have an already-namespaced namespace in the session you pass to the client, so all references to this session namespace have been removed. For the sake of a default $_SESSION $_SESSION['oauthio'] is used.
In this rewrite I'll substitute Guzzle for unirest. I'll follow the patterns in the excellent KeenLabs client https://github.com/keenlabs/KeenClient-PHP
I've created this ticket as a forum to bring ideas about a rewrite together and work out the issues between the current and rewrite.
can you provide instructions on how to setup the php sdk without using composer?
Google authentication popup throws this error:
Error: invalid_request
Missing required parameter: scope
Request Details
response_type=code
access_type=online
redirect_uri=https://oauth.io/auth
state=1UGF0qnuONPgnZDeSK7oT4hl348
client_id=553071262209-g066a765h33jv3tp79ov88c9l0lsmd3l.apps.googleuserconten
Is there any way to send scope in the initial authorization request - this is a similar issue to the Facebook one I posted earlier.
File: src/OAuth_io/OAuth.php
'url' => $this->injector->config['oauthd_url'] . '/auth/access_token',
should be
'url' => $this->injector->config['oauthd_url'] . '/access_token',
as defined in oauthd here
server.post(config.base + '/access_token', function(req, res, next) {
The unified method: $request_object->me() for facebook does not return the users primary email.
Is there another way to get the facebook email alongwith the basic_profile | aka is there a way to add permission scope
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for oauth-io/oauth 0.2.0 -> satisfiable by oauth-io/oauth[0.2.0].
- oauth-io/oauth 0.2.0 requires mashape/unirest-php dev-master -> no matching package found.
Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your minimum-stability setting
see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.
Read <http://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.
the me endpoint still doesn't work for me... how do i get this to use the data provided in the me.js files. i've found out that this file is returned when i do the following request but i can't find anything else that uses it.
https://domain.com:6284/api/providers/:provider/user-mapping
i've tried both of the available methods:
$req->get('/me')
$req->me()
i also don't think the me.js files are completely accurate.
Due to the fact that the composer file has mashape/unirest-php pointing to dev-master rather than a specific release, and also the fact that the sdk is not compatible with the 2.0 version of unirest; the sdk no longer works.
I will attempt to fix and send a PR
Hi, I have a javascript client and a laravel backend. I successfully got state token by calling generateStateToken()
method, but then I send that to $this->oauth->auth()
method I get Invalid Format error. Can you please tell me what this error means and what I am doing wrong.
Client Side
var selectedAuth = 'facebook';
$.post('http://localhost/auth/v1/social', {provider: selectedAuth, get_state_token: 1}, function(data){
OAuth.popup(selectedAuth)
.done(function(result) {
console.log(result);
$.post('http://localhost/auth/v1/social', {provider: selectedAuth, code: data.token, access_token: result.access_token}, function(data){
console.log(data);
}, 'json');
})
.fail(function (err) {
//handle error with err
});
}, 'json');
Server Side
// get state token
$token = $this->oauth->generateStateToken();
return response()->json(['status' => 'success', 'token' => $token]);
--- snip ---
// get access token from state token
$provider = 'facebook';
$request_object = $this->oauth->auth($provider, array(
'code' => $code
));
$credentials = $request_object->getCredentials();
I have verified that $code
does have the exact state token that I have received on the 1st step.
The value of $credentials
is as follows:
{"status":"error","data":{"code":"Invalid format"},"refreshed":false}
Please help me out here. This error occurs for twitter auth as well.
Not sure where to submit a bug report for your website's examples, so im submitting here
url: https://oauth.io/getting-started?php#ii-using-the-php-sdk-auth-the-user
first php code block reads:
$request_object = $oauth->auth('the_provider', array(
'code': $code
));
however php array key value pairs are separated with "=>" and javascript is separated with ":" so it should read
$request_object = $oauth->auth('the_provider', array(
'code' => $code
));
(the same example is in dashboard>try auth)
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.