google api 授权登录

配置信息:
client_id:2881223983 8fbmhnv90qqu90.apps.googleusercontent.com
project_id:letsf-5de
auth_uri:https://accounts.google.com/o/oauth2/auth
token_uri:https://oauth2.googleapis.com/token
auth_provider_x509_cert_url:https://www.googleapis.com/oauth2/v1/certs
client_secret:_ArbkfHbauyr1cAiDA
redirect_uris:https://xxx.com
javascript_origins:https://xxx.com/aa

账号密码
[email protected]
*****

中文参考手册(Web 服务器应用程序中使用 OAuth 2.0)
https://wiki.jikexueyuan.com/project/google-oauth-2/web-apps.html


1 第一步 获取code
 https://accounts.google.com/o/oauth2/auth?
        scope=https://www.googleapis.com/auth/userinfo.profile
        &redirect_uri=http://xxx.com/test/aa
        &response_type=code
        &client_id=288xn6ui9s8fbmhnv90qqu90.apps.googleusercontent.com
        &access_type=offline
        &approval_prompt=force

2 第二步 去回调地址 接收code 和 scope
https://api.letscom.com/test/aa
        ?code=4%2F0QHT413ihOGwOOTW-PeWI5XD1xIIpl7akx4m_f19Zt90kE7i1jC4AzzEmKZTFtZ31kJTvkOLA
        &scope=profile+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile#

3 获取access_token
https://accounts.google.com/o/oauth2/token
        code=4/0AGxDUoeXkhRUMRdCge3wT_4tRDNT0vLOtWXgihWEjVbKmk
        redirect_uri=http://xxx.com/test/aa
        &client_id=288122398339-acsrn1si5xmhnv90qqu90.apps.googleusercontent.com
        &scope=https://www.googleapis.com/auth/content
        &client_secret=_ArbOxauyr1cAiDA
        &grant_type=authorization_code

3 获取 access_token
https://www.googleapis.com/oauth2/v3/token
        ?refresh_token=1//0ehlQgdxRAAGA4SNwF-L9IrqbxP-N5zUZe7TmIxvqgopB_uP0Do5pN716GpmO8eg
        &client_id=288122398339-acsrnxnv90qqu90.apps.googleusercontent.com
        &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": "https://www.googleapis.com/auth/content",
    "token_type": "Bearer",
    "id_token": "eyJhbGciO...TqaYRxjjW5XhGOT8xA"
}

4 获取 用户信息
https://www.googleapis.com/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"
}
 

你可能感兴趣的:(google api 授权登录)