2017-08-28 54 views
0

我正嘗試使用ADFS和oauth2來驗證我的應用程序。我發現了很多文檔可以用azure服務(使用ADAL)來完成此操作。但是沒有關於如何使用本地服務器的信息。Xamarin:創建沒有天藍色的ADFS(Oauth2)客戶端

我測試了一個角度的應用程序下的所有信息和認證工程!

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>/...) 

回答

1

有很好的參考here但注意你需要ADFS 4.0來做到這一點。

對於ADFS 3.0。你的選擇是有限的。良好的概述here