2016-11-15 47 views
0

我已經成功地爲我的ASP.Net MVC客戶端配置了Identityserver4,並且一切正常。 現在我正在尋找開發一個Android應用程序客戶端。 MVC客戶端和Android客戶端使用相同的身份服務器進行身份驗證和授權。 因此,對於Android客戶端,我正在尋找"AppAuth-Android" GitHub庫。但是我找不到任何示例或有助於在IdentityServer4中使用該庫。我已閱讀「AppAuth-Android」庫的文檔,它說如何在IdentityServer4中使用AppAuth-Android?

通常,AppAuth可以與支持本機應用程序的任何授權服務器(AS)一起工作。

所以我的問題是1)如何配置我的Identity Server以使用Android應用程序。
2)如何在「AppAuth-Android」的幫助下驗證我的Android應用程序。

任何幫助,非常感謝。

有人可以爲「AppAuth-Android」創建一個標籤嗎?

+0

從IdentityServer的角度來看,爲客戶端配置混合授權類型和所需的PKCE。然後打開日誌記錄並查看客戶端連接時發生的情況。 – leastprivilege

+0

如果您發現AppAuth和IdentityServer4之間不兼容 - 請在IS4問題跟蹤器上打開一個問題。 – leastprivilege

+0

好的!我會試一試並更新你。謝謝 – Madhu

回答

0

Basiclly,您可以使用以下設置identityserver4

new Client 
      { 
       ClientId = "client.android", 
       RequireClientSecret = false, 
       ClientName = "Android app client", 
       AllowedGrantTypes = GrantTypes.Code, 
       RequirePkce = true, 
       RequireConsent = false, 

       RedirectUris = { "net.openid.appauthdemo://oauth2redirect" }, 
       AllowedScopes = 
       { 
        IdentityServerConstants.StandardScopes.OpenId, 
        IdentityServerConstants.StandardScopes.Profile, 
        IdentityServerConstants.StandardScopes.Email, 
        IdentityServerConstants.StandardScopes.Phone, 
        "api1" 
       }, 
       AllowOfflineAccess = true 
      } 

反正你可以參考https://github.com/IdentityServer/IdentityServer4/issues/479有關此問題的更多細節。

0

服務器端的數據應該與android應用中使用的數據相同。

一個客戶端向服務器端

new Client 
     { 
      ClientId = "myClientId", 
      ClientName = "myClientName", 
      AllowedGrantTypes = GrantTypes.CodeAndClientCredentials, 
      RequireConsent = false, 

      ClientSecrets = 
      { 
       new Secret("myClientSecret".Sha256()) 
      }, 

      RedirectUris = { "myRedirectUri://callback" }, 

      AllowedScopes = 
      { 
       IdentityServerConstants.StandardScopes.OpenId, 
       IdentityServerConstants.StandardScopes.Profile, 
       IdentityServerConstants.StandardScopes.Email, 
       IdentityServerConstants.StandardScopes.Phone, 
      }, 

      AllowOfflineAccess = true 
     } 

添加在Android應用程序,你應該有相同的clientIdclientSecretredirectUri ..

我已經用你應該AppAuth未-的Android庫中的樣本只需編輯gradle.properties中的數據,然後檢查它here

+0

請編輯您的答案與細節和解決方案不只是一個鏈接 – yass

相關問題