如何使用Google访问令牌获取用户配置文件 [英] How do I get user profile using Google Access Token

查看:19
本文介绍了如何使用Google访问令牌获取用户配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在测试通过Google访问令牌获取用户信息

http://www.mawk3y.net/glogin

单击登录按钮后,我被重定向至

https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=access_token_here

并获取一些JSON数据,如下所示

{
"issued_to": "my client id.apps.googleusercontent.com",
"audience": "my client id.apps.googleusercontent.com",
"user_id": "user id here",
"scope": "https://www.googleapis.com/auth/plus.login",
"expires_in": 3596,
"access_type": "online"
}

现在我需要知道如何提取用户名、地址并通过电子邮件发送任何帮助信息?

提前感谢

推荐答案

试试这个:

 var url = 'https://www.googleapis.com/plus/v1/people/me?access_token={access_token}';

  $.ajax({
    type: 'GET',
    url: url,
    async: false,
    success: function(userInfo) {
      //info about user
      console.log(userInfo);
      console.log('test');
    },
    error: function(e) {
      console.log('error');

    }
  });

这篇关于如何使用Google访问令牌获取用户配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆