Download the PHP package octoauth/oauth2-twitter-adapter without Composer
On this page you can find all versions of the php package octoauth/oauth2-twitter-adapter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download octoauth/oauth2-twitter-adapter
More information about octoauth/oauth2-twitter-adapter
Files in octoauth/oauth2-twitter-adapter
Package oauth2-twitter-adapter
Short Description An adapter to allow you to interact with the 'abraham/twitteroauth' OAuth1 library alongside the 'phpleague/oauth2-*' libraries
License MIT
Homepage https://github.com/8w/oauth2-twitter-adapter
Informations about the package oauth2-twitter-adapter
Twitter OAuth1 Wrapper for Consistency with phpleague/oauth2-client
Twitter is conspicously absent from the list of OAuth2 providers support by the phpleague's oauth2-client. That's because Twitter doesn't support OAuth2 for User Authentication, though they do offer OAuth 1.0 support.
This package provides a wrapper for the excellent abraham/twitteroauth
library (which uses OAuth 1.0 to interact with Twitter), so that it can be used more easily alongside the various PhpLeague's OAuth2 clients.
Installation
To install, use composer:
Usage
Begin Auth
Instantiate a TwitterOAuth1
client, passing in a mechanism for retaining the OAuth1 temporary token between page requests. A session-based store is provided, but if you run a session-less app you can very easily create your own implementation of OAuth1TemporaryTokenStore
to use a database or alternative:
Your user will now be sent off to the OAuth authorization page, and be redirected back to the redirectUri
configured above when they've either approved or denied the authorization.
Finish Auth
At your redirectUri
you should create the provider as before (or load it from the session if you cached it), check that the callback contains everything required for successful authentication and then complete the login. At that point you'll have an AccessToken
which you can use as you wish - to retrieve the ResourceOwner
in the example below.
Make API Calls
Now you've got an access token, you can make calls to the Twitter REST APIs on behalf of the user:
Easing Use Alongside OAuth2-Clients
In order to complete the user authorization process without caring whether you're using an OAuth1.0 or OAuth2 provider, wrap your phpleague/oauth2-client implementation in the provided LeagueOAuth2Adapter
, so that it implements the ProviderInterface
. You can then interact with the adapter the same way as described above: