Releases: oauth-io/sdk-php
Version 0.3.2
Version 0.3.0
This version removes the need to use any front-end SDK to perform the authentication and API calls from the server.
All you need to do now is to use the redirect
method from an endpoint of your choice (e.g. /signin
), and give it a callback url like this:
$oauth->redirect('the_provider', '/callback/url');
This will automatically redirect your user to the provider's login and permission validation pages. Once the user has accepted your permission, he will be redirected to the callback url, where you'll be able to finish the authentication like this:
$request_object = $oauth->auth('the_provider', array(
'redirect' => true
));
$me = $request_object->me();
echo $me['name'];
This process still saves the user's credentials to the session and lets you retrieve a request object from them in any endpoint, once the authentication has been performed:
//From other endpoints, once the authentication has been performed
$request_object = $oauth->auth('the_provider');
You can also still save the credentials manually and restore them in a new request object later:
$credentials = $request_object->getCredentials();
//Save the credentials
//...
//Restore them later
$request_object = $oauth->auth('the_provider', array(
'credentials' => $credentials
));
This update does not change the fact that tokens are automatically refreshed if a refresh token is available.
Version 0.2.1
This version allows you to use oauthd with a specified base
field:
// By default the base field is '/' in oauthd
$oauth->setOAuthdURL('http://your_oauthd.com', '/');
Version 0.2.0
- New, more polyvalent auth method
- Token renewal support when available
The 0.2.0
changes a bit the syntax to perform the authentication and to retrieve a request object to make API requests.
Authenticating the user with a code
$request_object = $oauth->auth('provider', array(
'code' => 'the_code_you_got_from_the_front_end'
));
This saves also the credentials in the session for the duration of the user's visit.
Authenticating the user from the session
$request_token = $oauth.auth('provider');
Authenticating the user from saved credentials
You can save a user's credentials (what's returned by OAuth.io, an array containing the access_token
, refresh_token
, etc) in the data storage of your choice. To retrieve the credentials, do this:
$credentials = $request_object->getCredentials();
Later, you can use this array like this to rebuild a $request_object
:
$request_token = $oauth->auth('provider', array(
'credentials' => $credentials
));
Note that the credentials are automatically refreshed through the
auth
method if the access token is expired.
Version 0.1.0
This version of the SDK allows you to implement OAuth.io's server side flow on your PHP backend. The following features are supported :
- state token generation
- access_token retrieval server-side
- standard API requests .get|post|put|delete|patch
- unified me() request
To install this version, just add the following in your composer.json dependencies list :
"require": {
...
"oauth-io/oauth": "0.1.0"
...
},