function oauth2_client_set_redirect in OAuth2 Client 8
Same name in this branch
- 8 oauth2_client.module \oauth2_client_set_redirect()
- 8 oauth2_client.api.php \oauth2_client_set_redirect()
Same name and namespace in other branches
- 7.2 oauth2_client.module \oauth2_client_set_redirect()
- 7.2 oauth2_client.api.php \oauth2_client_set_redirect()
- 7 oauth2_client.module \oauth2_client_set_redirect()
Set a redirect request.
This can be used by other oauth2 clients to integrate with oauth2_client, i.e. to use the same client that is registered on the server for the oauth2_client.
The oauth2_server sends the authorization reply to the redirect_uri that is registered for the client, which is the one corresponding to oauth2_client. If another oauth2 client would like to get this authorization reply, it has to set a redirect request with this function, and then oauth2_client will forward the reply to it.
Example: ``` $state = md5(uniqid(rand(), TRUE)); $hybridauth_config['state'] = $state; $hybridauth_config['redirect_uri'] = oauth2_client_get_redirect_uri(); oauth2_client_set_redirect($state, array( 'uri' => 'hybridauth/endpoint', 'params' => array( 'hauth.done' => 'DrupalOAuth2', ) )); ```
Parameters
string $state: The random parameter that is used on the authentication url in order to mittigate CSRF attacks. In this case it is used as a key for identifying the authentication request.
array $redirect: Associative array that contains the keys:
- 'uri': the uri of the oauth2 client that is requesting a redirect
- 'params': associative array of other parameters that should be appended to the uri, along with the $_REQUEST.
1 call to oauth2_client_set_redirect()
- TestController::clientIntegration in tests/
oauth2_client_test/ src/ Controller/ TestController.php - Client Integration.
File
- ./
oauth2_client.module, line 101 - Provides OAuth2 client functionality.
Code
function oauth2_client_set_redirect($state, array $redirect) {
OAuth2Client::setRedirect($state, $redirect);
}