简体   繁体   English

获取 Microsoft Graph 的访问令牌

[英]Get access token for Microsoft Graph

I have a web application in C# through which I'm trying to get access token for Microsoft Graph API. I'm able to get tokens through using Client secret, but don't want to get the token by using the client secret but get the token by other means, want to get tokens without client secrets.我在 C# 中有一个 web 应用程序,我试图通过它获取 Microsoft Graph API 的访问令牌。我可以通过使用客户端密钥获取令牌,但不想通过使用客户端密钥获取令牌但是得到通过其他方式获得令牌,想要获得没有客户机密的令牌。 I'm successfully getting the tokens using secrets and have stored them in KeyVault but getting an alert for " Explicit Credentials are being used for your application/service principals ", so require some alternative to get tokens.我成功地使用秘密获取令牌并将它们存储在 KeyVault 中,但收到“显式凭据正在用于您的应用程序/服务主体”的警报,因此需要一些替代方法来获取令牌。 Is there any way to get tokens without secrets.有没有什么办法可以不带秘密的获得代币。 Any help would be great.任何帮助都会很棒。

One can use ROPC oAuth grant based on username and password instead of using Client Secrets to get access tokens.可以使用基于用户名和密码的 ROPC oAuth 授权,而不是使用客户端机密来获取访问令牌。 Microsoft identity platform supports the OAuth 2.0 Resource Owner Password Credentials (ROPC) grant, which allows an application to sign in the user by directly handling their password. Microsoft 标识平台支持 OAuth 2.0 资源所有者密码凭据 (ROPC) 授权,它允许应用程序通过直接处理用户密码来登录用户。 Refer, https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-oauth-ropc Warning: Microsoft recommends you do not use the ROPC flow.参考, https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-oauth-ropc警告:Microsoft 建议您不要使用 ROPC 流程。 In most scenarios, more secure alternatives are available and recommended.在大多数情况下,可以使用并推荐更安全的替代方案。 This flow requires a very high degree of trust in the application, and carries risks which are not present in other flows.此流程需要对应用程序有非常高的信任度,并且会带来其他流程中不存在的风险。 You should only use this flow when other more secure flows can't be used.您应该仅在无法使用其他更安全的流程时才使用此流程。

It is not a recommended way to use without client secret since due to security concerns.出于安全考虑,不推荐在没有客户端密码的情况下使用。

If you still don't want to use client secret go with implicit grant flow which we can easily implement on the front end by maintaining SPA and passing token to the backend如果您仍然不想使用带有隐式授权流的客户端密码 go,我们可以通过维护SPA并将令牌传递到后端轻松地在前端实现

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

相关问题 Microsoft Graph API - 如何在没有授权码的情况下获取访问令牌? - Microsoft Graph API - how to get access token without Authorization Code? 从已经为Microsoft Graph资源生成的访问令牌中获取SharePoint Access令牌(https://graph.microsoft.com) - Get SharePoint Access token from already generated access token for the Microsoft Graph resource (https://graph.microsoft.com) 访问令牌验证失败 Microsoft Graph API - Access token validation failure Microsoft Graph API 如何在Microsoft Graph API C#中获取用户ID和访问令牌 - How to get User Id and Access Token in Microsoft Graph API C# 通过Microsoft Graph访问不包含SCP(角色)声明的令牌 - Access token not containing SCP (roles) claims via Microsoft Graph 如何在 Microsoft Graph API 的访问令牌中添加权限 - How to add the permissions in the access token of Microsoft Graph API 使用 Microsoft.Identity.Client 额外获取刷新令牌以访问令牌 - Get refresh token additionally to access token with Microsoft.Identity.Client Microsoft graph 无需用户即可访问以获取日历事件 - Microsoft graph get access without a user to get calendar events 如何刷新 Microsoft Graph 的令牌 - How to refresh a token for Microsoft Graph 如何在ASP.NET Core中为Azure AD请求正确的访问令牌以访问Microsoft Graph - How do request a correct access token in ASP.NET Core for Azure AD to access Microsoft Graph
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM