function oauth2_client_set_token in OAuth2 Client 8
Same name in this branch
- 8 oauth2_client.module \oauth2_client_set_token()
- 8 oauth2_client.api.php \oauth2_client_set_token()
Same name and namespace in other branches
- 7.2 oauth2_client.module \oauth2_client_set_token()
- 7.2 oauth2_client.api.php \oauth2_client_set_token()
- 7 oauth2_client.module \oauth2_client_set_token()
Share an access token with oauth2_client.
Another oauth2 client that has been successfully authenticated and has received an access_token, can share it with oauth2_client, so that oauth2_client does not have to repeat the authentication process again.
Example: $client_id = $hybridauth->api->client_id; $token = array( 'access_token' => $hybridauth->api->access_token, 'refresh_token' => $hybridauth->api->refresh_token, 'expires_in' => $hybridauth->api->access_token_expires_in, 'expiration_time' => $hybridauth->api->access_token_expires_at, 'scope' => $hybridauth->scope, ); $token_endpoint = $oauth2->api->token_endpoint; $client_id = $oauth2->api->client_id; $auth_flow = 'server-side'; $id = md5($token_endpoint . $client_id . $auth_flow); oauth2_client_set_token($id, $token);
File
- ./
oauth2_client.module, line 128 - Provides OAuth2 client functionality.
Code
function oauth2_client_set_token($id, $token) {
$tempstore = \Drupal::service('tempstore.private')
->get('oauth2_client');
$tokens = $tempstore
->get('token');
$tokens[$id] = $token;
$tempstore
->set('token', $tokens);
}