使用Azure AD V2.0(MSAL)和Asp .Net Core 2.0获取刷新令牌

编程入门 行业动态 更新时间:2024-10-24 12:24:05
本文介绍了使用Azure AD V2.0(MSAL)和Asp .Net Core 2.0获取刷新令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已经从Azure Ad V2.0终结点获得了access_token来调用Graph Api.但是我必须代表用户在api中执行一些操作.因此,当我的access_token过期时,我需要refresh_token进行续订.

I've got access_token from Azure Ad V2.0 endpoint to call Graph Api. But I have to do some actions in the api on behalf of user. So I need refresh_token to renew my access_token when it'll expire.

有什么方法可以在ASP .Net Core中使用MSAL获取刷新令牌?

Is there any way to get Refresh token using MSAL in ASP .Net Core?

在Microsoft documentaion中,他们告诉您可以通过请求/token终结点来做到这一点.但是我找不到使用MSAL的方法.

In microsoft documentaion they're telling it's possible to do by requesting /token endpoint. But I couldn't find how to do it using MSAL.

推荐答案

MSAL .NET不会公开刷新令牌,而是将其保留在内部,并代表应用程序处理所有令牌刷新和缓存逻辑.

MSAL .NET does not expose the refresh token, but rather keeps it internal and handles all token refresh and caching logic on the app's behalf.

您所引用的文档引用的是MSAL代表您完成的协议本身.它带有授权码(在最终用户登录后)到达/token端点,并被授予访问和刷新令牌.访问令牌的有效期为1小时,当它过期时,AcquireTokenSilent将自动对/token端点使用刷新令牌来获取新的访问令牌.

The docs you're referring to are referencing the protocol itself that MSAL is completing on your behalf. It goes to the /token endpoint with an authorization code (after the end user signs in), and is issued an Access and Refresh token. The Access Token is valid for 1 hour, and when it's expired, AcquireTokenSilent will automatically use the refresh token against the /token endpoint to get a new access token.

更多推荐

使用Azure AD V2.0(MSAL)和Asp .Net Core 2.0获取刷新令牌

本文发布于:2023-11-14 09:13:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1586812.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:令牌   MSAL   Azure   AD   Core

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!