0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

PHPでGoogle Identity Platformにログイン

Posted at

REST APIでverifyPasswordを呼び出します。
一部設定ファイルの呼び出しはLaravelですが。keyは取得した任意のキーを使います。

レスポンスにはidTokenやrefreshTokenが含まれたJSONが返ってきます。

$root_url = 'https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyPassword';
$url = $root_url.'?key='.ENV('GOOGLE_IDENTITY_KEY');
        
//POSTする
$context = array(
     'http' => array(
           'method'  => 'POST',
           'header'  => implode("\r\n", array('Content-Type: application/x-www-form-urlencoded',)),
           'content' => http_build_query($data)
      )
);

try 
{
    //実行と取得
    $json_response = file_get_contents($url, false, stream_context_create($context));
} 
catch (\Throwable $th) 
{
    ~~~
}

//配列に変換
$google_response = json_decode($json_response, true);
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?