Updated README.md

This commit is contained in:
Kasper Rynning-Tønnesen 2016-07-01 15:25:07 +02:00
parent c7ed6513f0
commit 3e59131386
2 changed files with 12 additions and 13 deletions

View File

@ -61,8 +61,6 @@ class OAuth2 {
$result = curl_exec($this->create_curl($url, false, $params)); $result = curl_exec($this->create_curl($url, false, $params));
$result_obj = json_decode($result, true); $result_obj = json_decode($result, true);
$access_token = $result_obj['access_token']; $access_token = $result_obj['access_token'];
$expires_in = $result_obj['expires_in'];
$expires_at = time() + $expires_in;
return $access_token; return $access_token;
} }

View File

@ -1,19 +1,21 @@
# General OAuth2-Client # General Authorization Code Flow OAuth2-Client
This client is made for Authorization Code Flow for now.
To use this general OAuth2 client-class, include it with To use this general OAuth2 client-class, include it with
``` ```
require_once('OAuth2Client.php'); 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,
"redirect_uri" => $redirect_uri, "redirect_uri" => $redirect_uri,
"auth" => $auth, "auth" => $auth,
"token" => $token, "token" => $token,
"authorization_type" => $authorization_type, "authorization_type" => $authorization_type,
"session" => $session, "session" => $session,
"verify" => $verify, "verify" => $verify,
"grant_type" => $grant_type, "grant_type" => $grant_type,
"response_type" => $response_type "response_type" => $response_type
]); ]);
``` ```
@ -23,7 +25,7 @@ To use this general OAuth2 client-class, include it with
```(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 ```(string) $authorization_type``` defaults to Bearer
```(boolean) $session``` specifies whether the state is to be saved in _SESSION storage, defaults to false ```(boolean) $session``` specifies whether the state is to be saved in _SESSION storage, defaults to false
@ -52,4 +54,3 @@ To get identity
```(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.