且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何获取通过 OAuth io 记录的当前用户详细信息

更新时间:2023-01-27 11:43:28

你可以在你的 javascript 中使用 OAuth.callback 和 OAuth.redirect(如果这是你正在使用的).

you can use OAuth.callback in pair with OAuth.redirect (if that is what you are using) in your javascript.

您可以从客户端或服务器端获取您的用户详细信息.

You can either get your user details from client side or server side.

例如

OAuth.redirect('google', "/test");

在/test:

OAuth.callback('facebook', function(err, result) {
  // the oauth token is in result.access_token
  result.get("/oauth2/v1/userinfo", function(data) { // or /plus/v1/people/me
    alert('Hello ' + data.displayName)
  });
});

如果您打算从服务器端进行 api 调用,在 Java 中,您可以将令牌(或代码)传递到您的服务器,然后使用 google java api(构建 GoogleCredential)或直接 http 调用

if you are planning to do the api call from server-side, in java, you can pass the token (or code) to your server and either use the google java api (building a GoogleCredential) or direct http calls