配置信息:
client_id:2881223983 8fbmhnv90qqu90.
project_id:letsf-5de
auth_uri:/o/oauth2/auth
token_uri:/token
auth_provider_x509_cert_url:/oauth2/v1/certs
client_secret:_ArbkfHbauyr1cAiDA
redirect_uris:
javascript_origins:/aa
账号密码
xxx@
*****
中文参考手册(Web 服务器应用程序中使用 OAuth 2.0)
/project/google-oauth-2/web-apps.html
1 第一步 获取code
/o/oauth2/auth?
scope=/auth/userinfo.profile
&redirect_uri=/test/aa
&response_type=code
&client_id=288xn6ui9s8fbmhnv90qqu90.
&access_type=offline
&approval_prompt=force
2 第二步 去回调地址 接收code 和 scope
/test/aa
?code=4%2F0QHT413ihOGwOOTW-PeWI5XD1xIIpl7akx4m_f19Zt90kE7i1jC4AzzEmKZTFtZ31kJTvkOLA
&scope=profile+https%3A%2F%%2Fauth%2Fuserinfo.profile#
3 获取access_token
/o/oauth2/token
code=4/0AGxDUoeXkhRUMRdCge3wT_4tRDNT0vLOtWXgihWEjVbKmk
redirect_uri=/test/aa
&client_id=288122398339-acsrn1si5xmhnv90qqu90.
&scope=/auth/content
&client_secret=_ArbOxauyr1cAiDA
&grant_type=authorization_code
3 获取 access_token
/oauth2/v3/token
?refresh_token=1//0ehlQgdxRAAGA4SNwF-L9IrqbxP-N5zUZe7TmIxvqgopB_uP0Do5pN716GpmO8eg
&client_id=288122398339-acsrnxnv90qqu90.
&client_secret=_Arbxyr1cAiDA
&grant_type=refresh_token
返回数据:
{
"access_token": "ya29.a0AfH6SM7...DL4-Fl10-CbmP-HbY",
"expires_in": 3599,
"refresh_token": "1//0edhlgop...B_uP0Do5pN716GpmO8eg",
"scope": "/auth/content",
"token_type": "Bearer",
"id_token": "eyJhbGciO...TqaYRxjjW5XhGOT8xA"
}
4 获取 用户信息
/oauth2/v1/userinfo?alt=json&access_token=ya29...xZf1feo01v7ss7SFCwIw
返回用户信息
{
"id": "115304811039070037277",
"name": "xuelei lin",
"given_name": "xuelei",
"family_name": "lin",
"picture": "https://lh3.googleusercontxpiT_enTQ8GU0us5CkPgkh4bP8VR4vLpN0q",
"locale": "zh-CN"
}