简体   繁体   English

如何使用用户凭据从 azure 广告生成不记名令牌

[英]How to generate a bearer token from azure ad with user credentials

I have a .net core API and JWT token authentication code is added in the application.我有一个 .net 核心 API,并且在应用程序中添加了 JWT 令牌身份验证代码。 My problem is how can I generate the bearer token from any application so that I can authenticate the request.我的问题是如何从任何应用程序生成不记名令牌,以便我可以对请求进行身份验证。 I am not able to generate the bearer token.我无法生成不记名令牌。

I have tried lots of options like from Postman GetNewAccessToken.我尝试了很多选项,例如 Postman GetNewAccessToken。 Its asks for Single sign-on but after sign-in open the Microsoft office website in a new window.它要求单点登录,但登录后在新窗口中打开 Microsoft Office 网站。 How can I get bearer token from Postman?如何从 Postman 获取不记名令牌?

Is there is any way for getting the bearer token from C# application using users's credentials or using single sign on?有什么方法可以使用用户的凭据或使用单点登录从 C# 应用程序获取不记名令牌?

在此处输入图片说明

在此处输入图片说明

I need a bearer token just to authenticate my request.我需要一个不记名令牌来验证我的请求。

Open up your F12 developer tools in your browser, look up an authenticated request and have a look at the Authentication header.在浏览器中打开 F12 开发人员工具,查找经过身份验证的请求并查看身份验证标头。 It has a current version of a Bearer token.它具有当前版本的不记名令牌。

For instance:例如:

  • Go to the Graph Explorer preview转到Graph Explorer 预览
  • Sign in to Graph Explorer (top left )登录 Graph Explorer(左上角
  • Open up F12 developer tools打开 F12 开发者工具
  • Run the Me query运行 Me 查询
  • See the request to /me in the Network tab在“网络”选项卡中查看对/me的请求
  • Inspect the request headers and find the Authorization header检查请求标头并找到授权标头

来自 Graph Explorer 的授权标头 - 预览

如果要以编程方式检索令牌,则应查看 Microsoft 身份验证库 (MSAL): https ://docs.microsoft.com/en-us/azure/active-directory/develop/msal-overview,更具体地说是MSAL。网

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM