PHPackages                             oauth-io/oauth - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. oauth-io/oauth

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

oauth-io/oauth
==============

OAuth that just works !

0.3.2(11y ago)90141.4k↓25%8[6 issues](https://github.com/oauth-io/sdk-php/issues)[1 PRs](https://github.com/oauth-io/sdk-php/pulls)1Apache2PHPPHP &gt;=5.3.0CI failing

Since May 7Pushed 9y ago10 watchersCompare

[ Source](https://github.com/oauth-io/sdk-php)[ Packagist](https://packagist.org/packages/oauth-io/oauth)[ RSS](/packages/oauth-io-oauth/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (2)Versions (9)Used By (1)

OAuth.io PHP SDK
================

[](#oauthio-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](https://oauth.io/docs/api-reference/server/php) on OAuth.io.

Features
--------

[](#features)

- Server-side OAuth authentication flow
- Requests to API from the backend
- Unified user information (`.me()` method) requests when available
- Access token renewal with the refresh\_token when available

Common use-Case
---------------

[](#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
------------

[](#installation)

First of all, you'll need to set your app's backend to **PHP** in your OAuth.io [dashboard](https://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 :

```
 "require": {
        ...
        "oauth-io/oauth": "0.3.0"
        ...
    },
```

Then run in the console :

```
$ composer install
```

Using the SDK
-------------

[](#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](https://oauth.io/key-manager)) :

```
