小编bur*_*rgi的帖子

Microsoft Live API-访问令牌无效

我正在尝试实现“使用Outlook.com登录”流程,该流程涉及客户端和服务器代码。流程是:

  1. 从客户端将用户重定向到:

https://login.live.com/oauth20_authorize.srf?client_id= <client_id>&response_type = code&redirect_uri = <登录html页面>&scope = openid + offline_access + profile + https:%2f%2foutlook.office.com%2fmail。发送+ https:%2f%2foutlook.office.com%2fcontacts.read + onedrive.readwrite

  1. 我将代码返回到html页面,并将其发布到我的java服务器。

  2. 在服务器端,我使用代码来获取访问和刷新令牌,并通过POST请求访问:https : //login.live.com/oauth20_token.srf

正文中的下一个参数:client_id,redirect_uri,client_secret,grant_type =“ authorization_code”和code = <上一步中的代码>。

我收到了access_token和refresh_tokem,它们应该有效1小时。

  1. 仍然在服务器上,我称URL

https://apis.live.net/v5.0/me?access_token= <我刚刚获得的访问令牌>

并得到错误401:

{
   "error": {
      "code": "request_token_invalid", 
      "message": "The access token isn't valid."
   }
}
Run Code Online (Sandbox Code Playgroud)

这可能吗?

windows-live windows-live-id live-sdk

9
推荐指数
1
解决办法
542
查看次数

Google javascript登录API:无法离线访问

我正在尝试为服务器端应用实施Google登录,如Google文档中所示:用于服务器端应用的Google登录,但同意窗口从不要求离线访问.选择用户后,它会关闭并调用登录处理程序功能.

因此,当我获得一次性代码并将其发送到服务器时,我无法将其替换为刷新令牌,仅用于访问和id令牌.

这是我的客户端代码:

在HTML文件中:

<script src="https://apis.google.com/js/platform.js?onload=init" async defer></script>
Run Code Online (Sandbox Code Playgroud)

Javascript代码:

var auth2;
function init() {
    gapi.load('auth2', function() {
        auth2 = gapi.auth2.init({
            client_id: '<my client id>.apps.googleusercontent.com',
            scope: 'https://www.google.com/m8/feeds https://www.googleapis.com/auth/drive https://www.googleapis.com/auth/drive.appfolder'
        });
    });
    $('#signinButton').click(function() {
        auth2.grantOfflineAccess({'redirect_uri': 'postmessage'}).then(onSignIn);
    });
}

function onSignIn(authResult) {
    if (authResult['code']) {
    // Send the code to the server
    }
}
Run Code Online (Sandbox Code Playgroud)

Google控制台中的项目包含一个Web客户端凭据,其中包含相关的javascript源,并且没有授权的重定向URI.

我该怎么做才能强制同意窗口要求离线访问

javascript google-api google-oauth google-signin

5
推荐指数
1
解决办法
1928
查看次数