Download the PHP package oauth-io/oauth without Composer

On this page you can find all versions of the php package oauth-io/oauth. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package oauth

OAuth.io PHP SDK

OAuth that just works !

This SDK allows you to use OAuth.io from a PHP backend, to handle the authentication and API calls from your server instead of from your front-end, for 100+ API providers.

The current version of the SDK is 0.3.2. Older versions are deprecated.

You can also get nightlies by checking out our develop branch.

To get more information about this SDK and its method, please refer to its reference documentation on OAuth.io.

Features

Common use-Case

You don't want to use APIs directly from the front-end, but rather through web-services inside your PHP backend.

Installation

First of all, you'll need to set your app's backend to PHP in your OAuth.io dashboard.

This allows you to get a refresh token from the provider if available.

You can install it through Composer by adding the following dependency to your composer.json :

Then run in the console :

Using the SDK

The OAuth class is stored in the OAuth_io namespace. You need to include it in your file like this (make sure you have required the Composer autoloader file):

PSR-0 support

If you're using Composer with an autoloader, you can use the PSR-0 notation to use this package. Just put the following code at the top of your script :

Initialization

To initialize the SDK, you have to give it your OAuth.io's app's key and secret (you can grab them on the oauth.io Key-Manager) :

Note on session

You can give your own managed session array to the constructor so that if you already have a session manager, the SDK doesn't mess around with it :

Note on certificates

If you're using oauthd (the open source version of oauth.io) and that you don't have a verified ssl certificate yet (you should in the future if you want to put your code in production), you can disable the SSL certificate verification like this :

Authenticating the user

The first thing you need to do is to create an endpoint that will redirect your user to the provider's authentication page, so that the user can accept the permissions your app needs.

In this endpoint, call the redirect method like this:

This will automatically redirect your user to the provider's website. Once he has accepted the permissions, he will be redirected to the '/callback/url' on your app, where you'll be able to retrieve a request object.

In an endpoint associated to the '/callback/url', call the auth method with the redirect option set to true to get a request object, like this:

$request_object is an object that allows you to perform requests (see further down to learn how to), and that contains the user's credentials.

Using the session to get a request object

Usually, you'll want to make calls to the API several times while the user is connected to your app. Once you've authenticated the user once with a code, the session is automatically configured to work with the SDK.

Thus, you just need to do this to get a request object:

Saving credentials to re-generate a request object

You can also save the user's credentials to make requests in a cron. You can get the credentials array from a request object like this :

Then, when you want to reuse these credentials, you can rebuild a $request_object from them:

Making requests to the API

Once you have a request object, you can make requests to the API.

You can also call the me(array $filters) method from that request object. This method returns a unified array containing information about the user.

You can refer to the OAuth.io me() feature to get more information about the fields that are returned by this method.

Refreshing the token

If a refresh token is available and the access token is expired, the auth method will automatically use that refresh token to get a new access token.

You can force the renewal by passing the force_refresh field in the options array:

You can also directly refresh a credentials array like this:

Contributing to this SDK

Issues

Please discuss issues and features on Github Issues. We'll be happy to answer to your questions and improve the SDK based on your feedback.

Pull requests

You are welcome to fork and make pull requests. We appreciate the time you spend working on this project and we will be happy to review your code and merge it if it brings nice improvements :)

If you want to do a pull request, please mind these simple rules :

If you do so, we'll be able to merge your pull request more quickly :)

The SDK is written as a Composer module. You can install its dependencies like this :

Testing the SDK

We use PHPUnit to test the SDK. To test it, just run the following from the SDK root folder :

License

The SDK is released under the Apache2 license.


All versions of oauth with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.0
mashape/unirest-php Version 2.2.*
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package oauth-io/oauth contains the following files

Loading the files please wait ....