Merge branch 'master' of github.com:kasperrt/OAuth2-Client

This commit is contained in:
Kasper Rynning-Tønnesen 2016-07-01 11:31:08 +02:00
commit b5e137251d
2 changed files with 39 additions and 16 deletions

21
LICENCE Normal file
View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2016 Kasper Rynning-Tønnesen
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -1,7 +1,9 @@
# General OAuth2-Client # General OAuth2-Client
To use this general OAuth2 client-class, include it with To use this general OAuth2 client-class, include it with
``` require_once('OAuth2Client.php'); <<<<<<< HEAD
```
require_once('OAuth2Client.php');
$oauth2 = new OAuth2([ $oauth2 = new OAuth2([
"client_id" => $client_id, "client_id" => $client_id,
"client_secret" => $client_secret, "client_secret" => $client_secret,
@ -16,32 +18,32 @@ To use this general OAuth2 client-class, include it with
]); ]);
``` ```
(string) $client_id is client id of the OAuth2 application ```(string) $client_id``` is client id of the OAuth2 application
(string) $client_secret is client secret of the OAuth2 application ```(string) $client_secret``` is client secret of the OAuth2 application
(string) $redirect_uri is the specified redirect-uri for the OAuth2 application ```(string) $redirect_uri``` is the specified redirect-uri for the OAuth2 application
(string) $auth is the full url for authorization ```(string) $auth``` is the full url for authorization
(string) $token is the full token url ```(string) $token``` is the full token url
Optional - Optional -
(string) $authorization_type defaults to Bearer <<<<<<< HEAD
(boolean) $session specifies whether the state is to be saved in _SESSION storage, defaults to false ```(string) $authorization_type``` defaults to Bearer
(boolean) $verify is whether to verify SSL of host and peer, defaults to true ```(boolean) $session``` specifies whether the state is to be saved in _SESSION storage, defaults to false
(string) $grant_type defaults to 'authorization_code' ```(boolean) $verify``` is whether to verify SSL of host and peer, defaults to true
(string) $response_type defaults to 'code' ```(string) $grant_type``` defaults to 'authorization_code'
```(string) $response_type``` defaults to 'code'
To start the redirect phase To start the redirect phase
``` $oauth2->redirect($state); ``` ```$oauth2->redirect($state);```
($state defaults to false) ($state defaults to false)
To get access token To get access token
``` $oauth2->get_access_token(); ``` ```$oauth2->get_access_token();```
returns the access_token. returns the access_token.
@ -50,9 +52,9 @@ returns the access_token.
To get identity To get identity
``` $oauth->get_identity($access_token, $user_url); ``` ```$oauth->get_identity($access_token, $user_url);```
(string) $user_url is the endpoint for fetching info, example: https://auth.dataporten.no/userinfo ```(string) $user_url``` is the endpoint for fetching info, example: https://auth.dataporten.no/userinfo
returns the identity-object as returned from the OAuth2-provider. returns the identity-object as returned from the OAuth2-provider.