function oauth2_server_authorize_form_submit in OAuth2 Server 7
Submit callback for oauth2_server_authorize_form.
Completes authorization and redirects back to the client.
File
- ./
oauth2_server.pages.inc, line 127 - Page callbacks for the OAuth2 Server module.
Code
function oauth2_server_authorize_form_submit($form, &$form_state) {
global $user;
// A login happened. Create the request with parameters from the session.
if (!empty($_SESSION['oauth2_server_authorize'])) {
$request = new OAuth2\Request($_SESSION['oauth2_server_authorize']);
unset($_SESSION['oauth2_server_authorize']);
}
else {
$request = OAuth2\Request::createFromGlobals();
}
$authorized = $form_state['triggering_element']['#authorized'];
$server = $form_state['build_info']['args'][1];
// Finish the authorization request.
$response = new OAuth2\Response();
$oauth2_server = oauth2_server_start($server);
$oauth2_server
->handleAuthorizeRequest($request, $response, $authorized, $user->uid);
return oauth2_server_send_response($response);
}