MS Dynamics:为OAuth生成刷新令牌 [英] MS Dynamics : Generate Refresh Token for OAuth
问题描述
我正在使用MS Dynamics的OData api.在这里,我们使用oauth
进行身份验证我正在使用Web Api,因此我们遵循以下参考.
我们遵循的步骤:
1 .将应用程序注册到Microsoft Azure:
2 .使用ADAL.js获取令牌. -尝试使用ADAL C#sdk,但由于登录窗口对话框无法弹出到Asp.Net Core Web Api项目中而失败.
Ref:
异常:该方法或操作未实现. 在
Microsoft.IdentityModel.Clients.ActiveDirectory.Internal.Platform.WebUIFactory.CreateAuthenticationDialog(IPlatformParameters
参数) 您能指导我们如何在Web Api(Asp.net Core)中刷新令牌.以及如何在MS Dynamics OAuth中获取refresh_token.您还有其他访问令牌/刷新令牌的方法吗? 注意:我们只允许一次从html页面登录oauth对话框并存储给定的令牌.我们必须使用相同的令牌来生成新令牌,或者使用其他任何方式来刷新令牌(第二次不出现提示对话框),以便在MS Dynamics OData Web Api中使用.
我正在使用Asp.net Core Web API项目在动力学之间进行交互. 用法: AuthenticationResult authenticationResult = authenticationContext.AcquireTokenAsync(ClientConfig.CRMOrgUrl,clientcred).结果; 参考: I am using OData api of MS Dynamics. Here we are doing authentication using oauth I am taking reference from
Ref : https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/developer-guide?view=dynamics-ce-odata-9 I am using Web Api so we followed below reference. Steps we have follow : 1. Registered an app to Microsoft Azure: 2. Acquire token using ADAL.js.
- Tried with ADAL C# sdk but it gets failed as dialog for login window could not pop out into Asp.Net Core Web Api project. To Generate token we are only using ApplicationId , ResourceUrl (dynamics resource url). 3. Pass as Bearer token to the rest api’s . It worked. Need : We have to refresh token, if the token get expired. We tried using c# ADAL SDK that is specified into the document itself.
Exception : The method or operation is not implemented. at
Microsoft.IdentityModel.Clients.ActiveDirectory.Internal.Platform.WebUIFactory.CreateAuthenticationDialog(IPlatformParameters
parameters) Can you guide us, how can we refresh token in Web Api (Asp.net Core). And how can we get refresh_token in MS Dynamics OAuth. Do you have any other approach to access token / refresh token? Note : We only allow login oauth dialog box from html page once and store the given token. We have to use either same token to generate new token or any other way to refresh token(without prompt dialog second time) to be use in MS Dynamics OData Web Api.
I am using Asp.net Core Web API Project to perform interaction between dynamics. Usage: AuthenticationResult authenticationResult = authenticationContext.AcquireTokenAsync(ClientConfig.CRMOrgUrl, clientcred).Result; Reference: 这篇关于MS Dynamics:为OAuth生成刷新令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
AuthenticationContext authContext =
new AuthenticationContext("https://login.windows.net/common/", false);
AuthenticationResult result = await authContext.AcquireTokenAsync(resource, clientId, new Uri(redirectUrl), new PlatformParameters());