Android sample using AppAuth-Android with identity server 4
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.idea
app
gradle/wrapper
.gitignore
CODE_OF_CONDUCT.md
LICENSE
README.md
build.gradle
gradle.properties
gradlew
gradlew.bat
settings.gradle

README.md

AppAuth with IdentityServer 4 for android

You can now use the AppAuth library with WebView check this

Android sample using AppAuth-Android with IdentityServer4

Identity Server on the backend

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
           }
  }

Edit the data in the gradle.properties file

clientId= "myClientId"
clientSecret= "myClientSecret"
redirectUri= "myRedirectUri://callback"
scope= "openid offline_access"
authorizationEndpointUri= "myAuthorizationEndpointUri"
tokenEndpointUri= "myTokenEndPointUri"
registrationEndpointUri= "myRegistrationEndPointUri"
responseType= "code"

Add the redirect uri to gradle.app :

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.3"
    defaultConfig {
       ...
        manifestPlaceholders = [
                'appAuthRedirectScheme': 'myRedirectUri' //Without ://callback
        ]
    }
}

Add the redirect uri to the RedirectUriReceiverActivity in manifest :

<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>