You can now use the AppAuth library with WebView check this
Android sample using AppAuth-Android with IdentityServer4
new Client
{
ClientId = _configuration["Clients:Mobile:Id"],
ClientName = "Mobile Application",
ClientSecrets = { new Secret(_configuration["Clients:Mobile:Secret"].Sha256())},
RedirectUris = {_configuration["Clients:Mobile:RedirectUrl"]},
PostLogoutRedirectUris = { _configuration["Clients:Mobile:PostLogoutRedirectUrl"] },
AllowedGrantTypes = GrantTypes.Code,
AllowAccessTokensViaBrowser = true,
RequireConsent = false,
AllowOfflineAccess = true,
RefreshTokenUsage = TokenUsage.ReUse,
AllowedScopes = {
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile
}
}
clientId= "myClientId"
clientSecret= "myClientSecret"
redirectUri= "myRedirectUri://callback"
scope= "openid offline_access"
authorizationEndpointUri= "myAuthorizationEndpointUri"
tokenEndpointUri= "myTokenEndPointUri"
registrationEndpointUri= "myRegistrationEndPointUri"
responseType= "code"
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
...
manifestPlaceholders = [
'appAuthRedirectScheme': 'myRedirectUri' //Without ://callback
]
}
}
<activity
android:name="net.openid.appauth.RedirectUriReceiverActivity"
android:theme="@style/Theme.AppCompat.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="myRedirectUri"/>
</intent-filter>
</activity>