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

账号密码
xxx@gmail.com
*****

中文参考手册(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"
}
 

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 7
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值