Download the PHP package samuelthomas2774/oauth-client without Composer
On this page you can find all versions of the php package samuelthomas2774/oauth-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download samuelthomas2774/oauth-client
More information about samuelthomas2774/oauth-client
Files in samuelthomas2774/oauth-client
Package oauth-client
Short Description An OAuth 2.0 Client library with built-in support for Facebook, Google, Microsoft, Yahoo, GitHub, LinkedIn & more.
License MIT
Homepage https://samuelthomas2774.github.io/oauth-client/
Informations about the package oauth-client
OAuth Client
An OAuth 2.0 Client library with built-in support for Facebook, Google, Microsoft, Yahoo, GitHub, LinkedIn & more.
You can see the current source running on Heroku from examples/all-2 here: https://oauth-client-test.herokuapp.com
Built-in providers
- Microsoft
- Yahoo
- GitHub
- Spotify
- Amazon
- Disqus
- TeamViewer
- WordPress.com
- Eventbrite
- Foursquare
- SpeechMore
- GitLab
- Mastodon
- Discord
- Slack
- DigitalOcean
- Gitter
- Deezer
- DeviantArt
- Twitch
- Vimeo
- Other, just create a new
OAuth2\\GenericOAuthProvider
object and include thebase_api_endpoint
,authorise_endpoint
andtoken_endpoint
options
Requirements and installation
This requires at least PHP 7.1.
Version | Supported |
---|---|
PHP 5.6 | No |
PHP 7.0 | No |
PHP 7.1 | Yes |
PHP 7.2 | Yes |
PHP 7.3 | Yes |
Composer
-
Add
"samuelthomas2774/oauth-client": "~3.0.0"
to your composer.json - Run Composer
This will automatically download the latest patch version.
Usage
-
Include
vendor/autoload.php
in all pages that need access to any provider
This will load any class in the src directory when used. - Create a new
OAuth2\\OAuth
object with the parameters$client_id
,$client_secret
and$options
The$options
array must have at leastbase_api_endpoint
,authorise_endpoint
andtoken_endpoint
.
-
To get a link to the authorise page:
-
To get an access token from the code that was returned:
-
To get an access token a refresh token:
-
To make API requests with the access token:
- To get/set the current access token: You do not need to do this at the start of the script to get the access token from the session, this is done automatically. Also, this function updates the access token in the session.
Built-in providers
Any other providers please contact me at https://samuelelliott.ml/#contact and I'll add it as soon as possible.
Provider | Class | Sign-up url |
---|---|---|
Amazon | OAuth2\Providers\Amazon\Amazon | https://developer.amazon.com/lwa/sp/overview.html |
Deezer | OAuth2\Providers\Deezer\Deezer | https://developers.deezer.com/myapps/create |
DeviantArt | OAuth2\Providers\DeviantArt\DeviantArt | https://www.deviantart.com/developers/register |
DigitalOcean | OAuth2\Providers\DigitalOcean\DigitalOcean | https://cloud.digitalocean.com/account/api/applications/new |
Discord P |
OAuth2\Providers\Discord\Discord | https://discordapp.com/developers/applications/ |
Disqus | OAuth2\Providers\Disqus\Disqus | https://disqus.com/api/applications/register/ |
Eventbrite | OAuth2\Providers\Eventbrite\Eventbrite | https://www.eventbrite.co.uk/myaccount/apps/new/ |
Facebook P |
OAuth2\Providers\Facebook\Facebook | https://developers.facebook.com/apps/ |
Foursquare | OAuth2\Providers\Foursquare\Foursquare | https://foursquare.com/developers/apps |
GitHub P |
OAuth2\Providers\GitHub\GitHub | https://github.com/settings/applications/new |
GitLab P I |
OAuth2\Providers\GitLab\GitLab | https://gitlab.com/profile/applications * |
Gitter | OAuth2\Providers\Gitter\Gitter | https://developer.gitter.im/apps/new |
Google P |
OAuth2\Providers\Google\Google | https://console.developers.google.com |
OAuth2\Providers\Instagram\Instagram | https://instagram.com/developer/clients/register/ | |
LinkedIn P |
OAuth2\Providers\Linkedin\Linkedin | https://www.linkedin.com/developer/apps/new |
Mastodon P I |
OAuth2\Providers\Mastodon\Mastodon | https://mastodon.social/settings/applications/new * |
Microsoft | OAuth2\Providers\Microsoft\Microsoft | https://account.live.com/developers/applications/create |
OAuth2\Providers\Pinterest\Pinterest | https://developers.pinterest.com/apps/ | |
OAuth2\Providers\Reddit\Reddit | https://www.reddit.com/prefs/apps | |
Slack P |
OAuth2\Providers\Slack\Slack | https://api.slack.com/apps |
SpeechMore P |
OAuth2\Providers\SpeechMore\SpeechMore | https://speechmore.ml/settings/api-clients |
Spotify | OAuth2\Providers\Spotify\Spotify | https://developer.spotify.com/my-applications/#!/applications/create |
TeamViewer | OAuth2\Providers\TeamViewer\TeamViewer | https://login.teamviewer.com/nav/api |
Twitch | OAuth2\Providers\Twitch\Twitch | https://dev.twitch.tv/dashboard/apps/create |
Vimeo | OAuth2\Providers\Vimeo\Vimeo | https://developer.vimeo.com/apps/new |
WordPress.com | OAuth2\Providers\WordPress\WordPress | https://developer.wordpress.com/apps/new/ |
Yahoo P |
OAuth2\Providers\Yahoo\Yahoo | https://developer.apps.yahoo.com/dashboard/createKey.html |
* This URL is for the default instance used
All the built-in providers implement OAuth2\UserProfilesInterface
, which adds an extra method to get a
OAuth2\UserProfile
object.
Some also implement OAuth2\UserPicturesInterface
(P
), which adds a method to get the URL of the user's
picture/avatar.
As GitLab and Mastodon support multiple instances they implement OAuth2\MultipleInstancesInterface
, which adds an
option and method to set the instance's URL.
Additional methods for providers
Discord have additional methods.
Extending the OAuth2 class
You can extend the OAuth2 and other classes to add new functions and make existing functions work differently:
You can then use the newly created class: