简体   繁体   English

如何使用 Microsoft Graph Javascript 客户端库获取刷新令牌?

[英]How to get a refresh token using the Microsoft Graph Javascript client library?

I am using the Microsoft graph Javascript client library to get a refresh token for a user.我正在使用Microsoft graph Javascript客户端库为用户获取刷新令牌。 I created an app that connects doctors and patients.我创建了一个连接医生和患者的应用程序。 I want to create and delete events on the doctors' calendars.我想在医生的日历上创建和删除事件。 I first need their authorization to access their outlook account.我首先需要他们的授权才能访问他们的 Outlook 帐户。 Unfortunately, when I make the api call to get the refresh token, I get back an access token and an id token but no refresh token.不幸的是,当我调用 api 来获取刷新令牌时,我得到了一个访问令牌和一个 id 令牌,但没有刷新令牌。 Can someone please help?有人可以帮忙吗?

Here's my code这是我的代码

const msalConfig = {
    auth: {
        clientId: process.env.OUTLOOK_OAUTH_CLIENT_ID,
        authority: process.env.OUTLOOK_OAUTH_AUTHORITY,
        clientSecret: process.env.OUTLOOK_OAUTH_CLIENT_SECRET
    },
    system: {
        loggerOptions: {
            loggerCallback(loglevel, message, containsPii) {
                console.log(message);
            },
            piiLoggingEnabled: false,
            logLevel: msal.LogLevel.Verbose,
        }
    }
};

// Create msal application object
const ouathClient = new msal.ConfidentialClientApplication(msalConfig);

const response = await ouathClient.acquireTokenByCode(tokenRequest);

I am using node js .我正在使用节点 js

This method can also be used to get the refresh token, Please refer this Microsoft documentation.此方法也可用于获取刷新令牌,请参阅此 Microsoft 文档。 To get refresh token 获取刷新令牌

Client Credentials flow does not support user context thus no refresh token is supported in this case. 客户端凭据流不支持用户上下文,因此在这种情况下不支持刷新令牌。

If you are using MSAL depending on whether you are using Public client (Mobile, Desktop or Single Page apps) where users sign-in to your app then you may need a refresh token and you should be using flows listed here如果您使用 MSAL,具体取决于您是否使用公共客户端(移动、桌面或单页应用程序),用户在其中登录到您的应用程序,那么您可能需要刷新令牌,并且您应该使用此处列出的流程

If you are using a private client like a serveside daemon then you dont need a refresh token.如果您使用的是像服务端守护进程这样的私有客户端,那么您不需要刷新令牌。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用节点 js 客户端库使用刷新令牌谷歌 oAuth2 获取新的访问令牌 - How to get a new access token using refresh token google oAuth2 using node js client library 微软图形无法获得刷新令牌 - microsoft graph cant get refresh token 如何使用 nodejs 和 node-fetch 从 Azure 为 Microsoft Graph 获取客户端令牌 - How to get a client token from Azure for Microsoft Graph using nodejs and node-fetch microsoft-graph api:从图中的刷新令牌获取新的访问令牌,而无需重定向URL - microsoft-graph api : Get new access token from refresh token in graph without redirect url Microsoft Graph API-无法刷新访问令牌 - Microsoft Graph API - cannot refresh access token 如何从Microsoft Graph API获取访问令牌? - How do I get an access token from Microsoft Graph API? 如何从节点脚本获取 Microsoft Graph API 访问令牌? - How to get Microsoft Graph API Access token from Node Script? 无法从 Microsoft oauth、msal node.js 库获取刷新令牌 - Can't get refresh token from microsoft oauth, msal node js library 从 Microsoft Graph for Azure 获取访问令牌 - Get access token from Microsoft Graph for Azure 如何使用来自 Ebay 的刷新令牌获取 access_token? - How to get access_token using refresh token from Ebay?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM