Skip to content

kinde-starter-kits/android-starter-kit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kinde Android SDK starter kit.

Requirements

Minimum supported Android SDK is Android SDK 21 (Android 5.0 Lollipop)

How to build

./gradlew build

How to integrate with Kinde

  1. Set up Kinde environment

    • Open Kinde settings in the Kinde Admin area.

    • Navigate to App keys section

    • Add urls for callback and logout:

      au.kinde://<your kinde url>//kinde_callback
      

      For example:

      au.kinde://coolapp.kinde.com/kinde_callback
      
  2. Setup Android project

    • Add meta-data to <application> section of your AndroidManifest.xml, for example:
      • Kinde domain (Token host):

        <meta-data
        android:name="au.kinde.domain"
        android:value="coolapp.kinde.com" />
        
      • Client ID:

        <meta-data
        android:name="au.kinde.clientId"
        android:value="12usan9gwef901bsdf09basd" />
        
      • Audience (Optional):

        <meta-data
        android:name="au.kinde.audience"
        android:value="example@example" />
        
  3. Build the application by calling ./gradlew build from the root directory of the starter kit

How to initialize

To get instance of SDK just instantiate KindeSDK (See KindeSDK) class with activity (See AppCompatActivity) and sdkListener (See SDKListener)
Optionally list of scopes can be provided to override default list.

##How to authorize

  1. With PKCE

  2. Without PKCE

login and register functions allow org_code parameter if there is need to sign in or sign up to a specific org

How to use API

SDK provides all available API methods as functions: just call one of functions to get data or pass information to server.

In case request is failed, null will be returned and additional information would be passed as exception to onException method of SDKListener See How to initialize section.

Supported exceptions:

  1. WrongThreadException. Thrown if API method is called from main (UI) thread
  2. NotAuthorizedException. Thrown if API method is called before login, so there is no token yet
  3. Exception. Thrown if API request is failed. Http response code and message will be passed

NOTE: Functions/methods targeting the Management API can only be accessed with tokens generated by the Client Credentials Auth flow at the moment. Since this SDK does not support the Client Credential flow, Management API functions are not available for use. In the future, tokens obtained via other flows would also be able to access the management API functions/methods.

Helper functions

SDK provides set of helper functions that allows to retrieve additional information:

  1. User Details
    • call getUserDetails function of SDK. If the ID token is present UserDetails object filled with data will be returned
  2. Claim
    • call getClaim function of SDK. Required parameter: claim to specify claim that should be retrieved. Optionally type of token can be chosen See TokenType. If claim is present in chosen token String with data will be returned. Otherwise null
  3. Permissions
    • call getPermissions function of SDK. Returns permissions claim from access token ClaimData
  4. Permission
    • call getPermission function of SDK. Required parameter: permission to specify permission that should be checked. Returns isGranted flag for requested permission ClaimData
  5. Permissions
    • call getOrganization function of SDK. Returns org_code claim from access token ClaimData
  6. Permission
    • call getUserOrganizations function of SDK. Returns org_codes claim from access token ClaimData
  7. Authenticated state
    • call isAuthenticated function of SDK. Returns true if accessToken is present and has valid signature

About

Starter kit for Android

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages