Git Product home page Git Product logo

android-starter-kit's Introduction

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

android-starter-kit's People

Contributors

romanrad avatar qualityvlad avatar rairaman avatar anhquan291 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.