Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/danrvp/oauth-php
Library for OAuth 1 and OAuth 2 workflows.
https://github.com/danrvp/oauth-php
autoload composer-package oauth oauth1 oauth2 php php-library php5 php7 php8
Last synced: about 2 months ago
JSON representation
Library for OAuth 1 and OAuth 2 workflows.
- Host: GitHub
- URL: https://github.com/danrvp/oauth-php
- Owner: DanRVP
- License: apache-2.0
- Created: 2022-07-09T16:08:03.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-04-19T14:28:21.000Z (over 1 year ago)
- Last Synced: 2024-10-13T12:03:43.613Z (3 months ago)
- Topics: autoload, composer-package, oauth, oauth1, oauth2, php, php-library, php5, php7, php8
- Language: PHP
- Homepage:
- Size: 59.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# OAuth-PHP
A PHP Library for OAuth 1 and OAuth 2 workflows.### Installation
```
composer require dan-rogers/oauth-php
```### Usage
####
OAuth 1 Example
- Use an array of options to create a config for your auth generation.
- Construct a new `OAuth1Config` object and use the array as the argument.
- Construct a new `OAuth1` object and use your `OAuth1Config` object as the argument.
- Call generateAuthorization().So long as you have provided the correct information for the OAuth1 step you are on, it will generate a valid auth header.
For more information on OAuth 1 usage see:
- https://oauth.net/1/
- https://www.rfc-editor.org/rfc/rfc5849```php
#!/usr/bin/php
'https://my_website/my_service/auth',
'oauth_consumer_key' => 'CONSUMER_KEY',
'consumer_secret' => 'CONSUMER_SECRET',
'realm' => 'MY_REALM',
'oauth_signature_method' => OAuth1Config::HMAC_SHA256,
]);$oauth = new OAuth1($config);
$auth_header = $oauth->generateAuthorization('https://third_party/token_endpoint', 'POST');// Example usage using PHP CURL
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => 'https://third_party/token_endpoint',
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => [
'Authorization: ' . $auth_header,
'Content-Length: 0',
],
]);$response = curl_exec($ch);
```