Giter VIP home page Giter VIP logo

oauth's Introduction

Build Status

OAuth Composer Package

Authorize users with your application using multiple OAuth 1 and OAuth 2 providers.

Examples

OAuth is split into two sections, clients and providers. A client is an application - perhaps a basic Twitter feed aggregator - which authenticates with an OAuth provider, which in this example would be Twitter itself. You can interact with any provider which is supported in the list below:

  • Appnet
  • Dropbox
  • Facebook
  • Flickr
  • Foursquare
  • GitHub
  • Google
  • Instagram
  • LinkedIn
  • Mailchimp
  • Mailru
  • PayPal
  • Soundcloud
  • Tumblr
  • Twitter
  • Vkontakte
  • Windows Live
  • Yandex
  • YouTube

Usage Example

In this example we will authenticate the user using Twitter.

$provider = \OAuth\OAuth::provider('Twitter', array(
	'id' => 'CLIENT_ID',
	'secret' => 'CLIENT_SECRET',
	'redirect_url' => 'URL_TO_THIS_PAGE'
));

$oauth = $provider->process(function($url, $token = null) {

    if ($token) {
        session_start();
        $_SESSION['token'] = base64_encode(serialize($token));
    }

    header("Location: {$url}");
    exit;

}, function() {

    session_start();
    return unserialize(base64_decode($_SESSION['token']));

});

print_r($oauth->getUserInfo());

If all goes well you should see a dump of user data.

Contribute

  1. Check for open issues or open a new issue for a feature request or a bug
  2. Fork the repository on Github to start making your changes to the develop branch (or branch off of it)
  3. Write a test which shows that the bug was fixed or that the feature works as expected
  4. Send a pull request and bug me until I merge it

oauth's People

Contributors

alexbilbie avatar andrew-s avatar bnvk avatar calvinfroedge avatar chrisnharvey avatar ckald avatar compilerrr avatar crodjer avatar dcrawkstar avatar fdiskas avatar it-can avatar jeremyvaught avatar mindplay-dk avatar philmareu avatar psp83 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

oauth's Issues

Remove requirement for redirect_url

The redirect_url parameter is only required when authenticating authenticating the user to the provider. If we are using setToken to set the tokens from a previous session then 'redirect_url' is irrelevant.

Add method for retreiving access token

Add a method into the Provider class to retrieve the access token and refresh token. This is so the implementer can store the tokens and use them to make requests to the respective API.

Use package as abstraction for oauth1 and oauth2

I have now split this repo up into two separate repositories chrisnharvey/oauth1 and chrisnharvey/oauth2.

When I have completed both of these packages, I will use them as requirements for this package and have some sort of abstraction so you can use both OAuth 1.0 and OAuth 2.0 in one API.

Update API

The current API is not as elegant as it could be.

I am currently devising a way to make this package easier to work with and to use closures less.

I have already added a method to make this work correctly with Laravel as writing to session does not occur until the end of the request. So using:

Session::put('token', $token);

header("Location: {$url}");
exit;

does not work because we are prematurely exiting the application which means the session is not written.

Use guzzle for all HTTP requests

Now that this package only supports PHP 5.3+, there is no reason why we shouldn't use Guzzle for HTTP requests.

This will provide a lot more flexibility and make our code look prettier ;)

Add method to set access token

If developers using this package are going to be using the 'call' method to call the respective API with their OAuth credentials then we are going to need a way for the developer to set the access token manually.

This will be used when access tokens are stored in the database for offline access etc.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.