我正在尝试使用ADFS和oauth2对我的应用进行身份验证。我发现了许多使用azure服务(使用ADAL)执行此操作的文档。但是没有关于如何使用本地服务器的信息。
我使用角度应用程序测试了下面的所有信息,并且验证工作正常!
public class AuthenticationService
{
public static string clientId = "uri:tst-amdm-website.mycompany.be";
private static string commonAuthority = "https://claim.mycompany.be/";
public static Uri returnUri = new Uri("http://www.google.be");
const string graphResourceUri = "uri:tst-amdm-api.mycompany.be";
public async void GetAccessToken(IPlatformParameters platformParameters)
{
AuthenticationResult authResult = null;
JObject jResult = null;
//List<User> results = new List<User>();
try
{
AuthenticationContext authContext = new AuthenticationContext(commonAuthority);
if (authContext.TokenCache.ReadItems().Any())
authContext = new AuthenticationContext(authContext.TokenCache.ReadItems().First().Authority);
authResult = await authContext.AcquireTokenAsync(graphResourceUri, clientId, returnUri, platformParameters);
var test = authResult.AccessToken;
}
catch (Exception ee)
{
//results.Add(new User { error = ee.Message });
//return results;
}
}
}
这是我得到的错误,但在角度中这个网址:https://claim.mycompany.be/
完美无缺。
'authority' Uri should have at least one segment in the path (i.e. https://<host>/<path>/...)