node.js - 为什么我对新访问 token 的请求没有返回新的刷新 token ?

标签 node.js office365api microsoft-graph-api

我正在使用以下代码以及我的刷新 token 来请求新的访问 token :

exports.getTokenFromRefreshToken = function (user, callback) {
    request.post({
        url:'https://login.microsoftonline.com/12345678-1234-1234-1234-2f189712345/oauth2/token',
        form: {
            grant_type: 'refresh_token',
            refresh_token: refresh_token,
            client_id: client_id,
            client_secret: client_secret,
            resource: 'https://graph.microsoft.com'
        }
    }, function(err, httpResponse, body) {
        if (!err) {
            var tokens = JSON.parse(httpResponse.body);
            console.log('getTokenFromRefreshToken() tokens = ' + JSON.stringify(tokens));
            callback(null, tokens);
        }
    })
};

httpResponse 包括我在发出原始 token 请求(来自 code)但没有新的刷新 token 时获得的所有内容。我的印象是我还会收到一个新的刷新 token 。不是这样吗?

最佳答案

仅当包含 offline_access 时,您才会获得新的刷新 token 范围。

引用:https://azure.microsoft.com/en-us/documentation/articles/active-directory-v2-scopes/

The offline_access scope gives your app access to resources on behalf of the user for an extended time. On the work account consent page, this scope appears as the "Access your data anytime" permission. On the personal Microsoft account consent page, it appears as the "Access your info anytime" permission. When a user approves the offline_access scope, your app can receive refresh tokens from the v2.0 token endpoint. Refresh tokens are long-lived. Your app can get new access tokens as older ones expire.

关于node.js - 为什么我对新访问 token 的请求没有返回新的刷新 token ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35005614/

相关文章:

javascript - 如何使用已有的 REST API 后端在 Angular 应用程序中实现登录系统

javascript - MarkLogic 8 Ingestion Job 在 JavaScript 中对集合进行非规范化

office365 - Microsoft Graph (Delta) - 不再包含在内?

c# - Office 365 API Active Directory 权限

python - Microsoft Outlook 图形事件 API : how to get different timezone?

node.js - 如何使用 Node.js 处理不同格式的文件,如 csv、xlsx、json、google docs

javascript - 从 Sequelize 中的另一个表中计数

api - Microsoft Graph API - 更新事件不会为与会者更新

microsoft-graph-api - 将图形消息保存到 .MSG 或 .EML 文件中

node.js - GET https ://graph. microsoft.com/v1.0/me 返回 401(未经授权),前提是具有 User.Read 权限的有效访问 token