Tools, FAQ, Tutorials:
Initiate Google OpenID Connect Access Token Request
How to initiate Google OpenID Connect Access Token Request?
✍: FYIcenter.com
The Google OpenID Connect Access Token Request should
be initiated from your application Web server.
This is why the authentication code flow is more secure
than the implicit flow, because the "id_token" value will
be received by Web server directly from the Azure AS service.
If you initiate the Access Token Request from end user's Web browser, your "id_token" value and application secret key value are exposed to the end user.
Here is a PHP code sample in the openID_receiver.php on the Web server to initiate Google OpenID Connect Access Token Request after received the authentication code from the sign-on authentication request call:
...
if (isset($_REQUEST["code"])) {
$code = $_REQUEST["code"];
$body = array(
'client_id' => $client_id,
'code' => $code,
'grant_type' => 'authorization_code',
'redirect_uri' => 'http://dev.fyicenter.com/openID_receiver.php',
'client_secret' => $client_secret
);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $body);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
$res = curl_exec($curl);
if($res === false){
echo 'Curl error: ' . curl_error($curl);
} else {
$res = json_decode($res, true);
# Access Token response is parsed into an array now
...
}
}
...
Note that you can only initiate the access token request with the POST method. Using the GET method may leave your secret key in the Azure server log files and become a security risk.
⇒ Process Google OpenID Connect Access Token Request
⇐ Google OpenID Connect Access Token Request
2019-02-05, ∼1781🔥, 0💬
Popular Posts:
Where to get a JSON.stringify() Example Code in JavaScript? Here is a good JSON.stringify() example ...
How To Read a File in Binary Mode in PHP? If you have a file that stores binary data, like an execut...
How to search for the first match of a regular expression using re.search()? The re.search() functio...
How To Pass Arrays By References? in PHP? Like normal variables, you can pass an array by reference ...
How to use "{{...}}" Liquid Codes in "set-body" Policy Statement? The "{{...}}" Liquid Codes in "set...