2017 © Pedro Peláez
 

library ohmy-auth

OAuth so easy.. you won't even believe it's OAuth

image

estebanmatias92/ohmy-auth

OAuth so easy.. you won't even believe it's OAuth

  • Wednesday, May 7, 2014
  • by estebanmatias92
  • Repository
  • 1 Watchers
  • 0 Stars
  • 200 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 25 Forks
  • 0 Open issues
  • 9 Versions
  • 0 % Grown

The README.md

ohmy-auth Build Status Scrutinizer Quality Score License

ohmy-auth (Oma) is a PHP library that simplifies OAuth into a single fluent interface:, (*1)

use ohmy\Auth;

$credentials = array(
    'key'    => 'key',
    'secret' => 'secret'
);

Auth::init($credentials)
    ->request('http://term.ie/oauth/example/request_token.php')
    ->access('http://term.ie/oauth/example/access_token.php')
    ->GET('http://term.ie/oauth/example/echo_api.php')
    ->then(function($data) {
       # got data
    });

Dependencies

Oma only requires PHP (>= 5.3) and the usual extensions for Curl (curl_init(), curl_setopt(), etc), JSON (json_encode(), json_decode()) and sessions (session_start(), session_destroy())., (*2)

Installing with Composer

The best way to install Oma is via Composer. Just add ohmy/auth to your project's composer.json and run composer install. eg:, (*3)

{
    "require": {
        "ohmy/auth": "*"
    }
}

Installing manually

If you prefer not to use Composer, you can download an archive or clone this repo and put src/ohmy into your project setup., (*4)

Two-Legged OAuth 1.0a

use ohmy\Auth;

# configuration
$credentials = array(
    'key'    => 'key',
    'secret' => 'secret'
);

# do 2-legged oauth
$termie = Auth::init($credentials)
              # oauth flow
              ->request('http://term.ie/oauth/example/request_token.php')
              ->access('http://term.ie/oauth/example/access_token.php')

# api call
$termie->GET('http://term.ie/oauth/example/echo_api.php')
       ->then(function($data) {
           # got data
       });

Three-Legged OAuth 1.0a

Note: This requires sessions in order to save data between redirects. This will not work properly without sessions!, (*5)

use ohmy\Auth;

# configuration
$credentials = array(
    'consumer_key'    => 'your_consumer_key',
    'consumer_secret' => 'your_consumer_secret',
    'callback'        => 'your_callback_url'
);

# do 3-legged oauth
$tumblr = Auth::init($credentials)
               # oauth flow
               ->request('http://www.tumblr.com/oauth/request_token')
               ->authorize('http://www.tumblr.com/oauth/authorize')
               ->access('http://www.tumblr.com/oauth/access_token');

# access tumblr api
$tumblr->GET('https://api.tumblr.com/v2/user/info')
       ->then(function($data) {
           # got user data
       });

Three-Legged OAuth 2.0

use ohmy\Auth;

# configuration
$credentials = array(
    'id'       => 'your_github_client_id',
    'secret'   => 'your_github_client_secret',
    'redirect' => 'your_redirect_uri'
);

# do 3-legged oauth
$github = Auth::init($credentials)
              # oauth flow
              ->authorize('https://github.com/login/oauth/authorize')
              ->access('https://github.com/login/oauth/access_token')
              # save access token
              ->finally(function($data) use(&$access_token) {
                 $access_token = $data['access_token'];
              });

# access github api
$github->GET("https://api.github.com/user?access_token=$access_token", null, array('User-Agent' => 'ohmy-auth'))
       ->then(function($data) {
           # got user data
       });

More examples

Licenses

  • PHP license: PHP License
  • ohmy-auth: New BSD License.

The Versions

07/05 2014

dev-master

9999999-dev https://github.com/sudocode/ohmy-auth

OAuth so easy.. you won't even believe it's OAuth

  Sources   Download

New BSD

The Requires

  • php >=5.3.0

 

oauth

22/04 2014

dev-one_single_auth

dev-one_single_auth https://github.com/sudocode/ohmy-auth

OAuth so easy.. you won't even believe it's OAuth

  Sources   Download

New BSD

The Requires

  • php >=5.3.0

 

oauth

22/04 2014

0.0.8

0.0.8.0 https://github.com/sudocode/ohmy-auth

OAuth so easy.. you won't even believe it's OAuth

  Sources   Download

New BSD

The Requires

  • php >=5.3.0

 

oauth

08/02 2014

0.0.6

0.0.6.0 https://github.com/sudocode/ohmy-auth

OAuth so easy.. you won't even believe it's OAuth

  Sources   Download

New BSD

The Requires

  • php >=5.3.0

 

oauth

02/02 2014

0.0.5

0.0.5.0 https://github.com/sudocode/ohmy-auth

OAuth so easy.. you won't even believe it's OAuth

  Sources   Download

New BSD

The Requires

  • php >=5.3.0

 

oauth

01/02 2014

0.0.4

0.0.4.0 https://github.com/sudocode/ohmy-auth

OAuth so easy.. you won't even believe it's OAuth

  Sources   Download

New BSD

The Requires

  • php >=5.3.0

 

oauth

01/02 2014

0.0.3

0.0.3.0 https://github.com/sudocode/ohmy-auth

OAuth so easy.. you won't even believe it's OAuth

  Sources   Download

New BSD

The Requires

  • php >=5.3.0

 

oauth

31/01 2014

0.0.2

0.0.2.0 https://github.com/sudocode/ohmy-auth

OAuth so easy.. you won't even believe it's OAuth

  Sources   Download

New BSD

The Requires

  • php >=5.3.0

 

oauth

31/01 2014

0.0.1

0.0.1.0 https://github.com/sudocode/ohmy-auth

OAuth so easy.. you won't even believe it's OAuth

  Sources   Download

New BSD

The Requires

  • php >=5.3.0

 

oauth