Giter VIP home page Giter VIP logo

okta-auth0-android-challenge's Introduction

Android Technical Exercise

License GitHub release (latest SemVer)

Challenge objectives

Write an Android app that features user authentication to consume our Coffee API. You will be provided with a starting Android app project and a Node API to run locally.

More information about the challenge objectives can be seen at here.

Key features

  • Implements login using Auth0 Universal Login with Authorization Code and PKCE flow
  • Remember user when comming back if it's already authenticated
  • Implements logut
  • Shows user information
  • Consumes coffee information from local Coffee API
  • Shares coffee information to 3rd party apps
  • Design two different item views depending on whether the coffee type is “hot” or “iced”

Missing features

  • Loading indicator while fetching list of coffees
  • Error handling if there is not internet connection
  • Error handling if Coffee API is not available

Known issues

  • Android 10 emulator's Web Browser does not allow to delete cookies and session data for the login page manually. Emulator must be wiped out.

Screenshots

Login screen

plot

External Universal Login

plot

Loggin in

plot

Main application activity

plot

Logout alert

plot

Requirements

Development environment requieres Java, for running the mobile application, and Node.js, for running the Coffee API.

Android

  • Android Studio 2020.3 (Artic Fox)
  • Java version 8 or above is required.
  • Android Compile SDK Level 30 is required.
  • Android API Level 21+
  • Build tools version 30.0.3

Node.js

  • Node.js 14.18.1 (LTS) or newer
  • npm 6

Android application

Running the (released) Android application on a emulator or mobile phone requieres Android 4.4 or newer. While using Android 10 is recommended as the development was done targeting that version.

Getting started

The application is already setup with a custom Auth0 application. If you would like to change the target Auth0 application, the following changes should be done.

Configuration

Android application

All configuration is defined in strings.xml

    <string name="AUTH0_SCHEME">https</string>
    <string name="AUTH0_DOMAIN">YOUR_AUTH0_DOMAIN</string>
    <string name="AUTH0_CLIENT_ID">YOUR_APPLICATION_CLIENT_ID</string>
    <string name="AUTH0_REDIRECT">com.auth0.androidexercise://universallogin/callback</string>
    <string name="COFFEE_SERVICE_URL">COFFEE_SERVICE_URL</string>
    <string name="API_AUDIENCE">coffee-api</string>
  • AUTH0_SCHEME Scheme makes reference to https because user will be redirected to a Web Application when logging in

  • AUTH0_DOMAIN Your Auth0 application domain

  • AUTH0_CLIENT_ID Application ClientID obtained from Auth0 Applications Dashboard

  • AUTH0_REDIRECT The URL defined in the Intent Filter of this application for handling authorization response. Should meet the one defined in Manifest.xml

  • COFFEE_SERVICE_URL The URL for the Coffee API (i.e.: http://localhost:3000/)

  • API_AUDIENCE The audience defined in Auth0 Dashboard for allowing users to access Coffee API

Node.js

In .env change AUDIENCE and ISSUER_BASE_URL to meet your configuration.

  • AUDIENCE should be the URL where the Coffee API is available.

  • ISSUER_BASE_URL is an URL with HTTPS as protocol and you Auth0 domain.

AUDIENCE=COFFEE_SERVICE_URL
ISSUER_BASE_URL=https://YOUR_AUTH0_DOMAIN/

Auth0

  1. Create a Native Application on your Auth0 Dashboard
  2. Setup the Application Allowed Callback URLs to match the defined in Manifest.xml as stated above.
  3. Define an API taking into account that Audience should match the one defined in the Node.js service. Also, application must have a read:coffees scope.
  4. Assign the role read:coffees to the users. This can be done in different ways as described in the API

Dependencies

Android

  • OkHttp 4.9 (as a HTTP client)
  • Retrofit 2.9 (for consuming REST APIs)
  • Gson 2.8 (decoding JSON with Retrofit)
  • Picasso 2.8 (for retrieving user profile picture)
  • Auth0 Java JWT 3.18 (for verifying and decoding JSON Web Token)
  • Hilt (Dagger) 2.38 (as a dependency injection manager)
  • AndroidX
  • Kotlin STDLib

NodeJS

  • Express 4.17
  • Morgan 1.10 (for logging purposes only)
  • Body parser 1.19 (for logging purposes only)

Documentation

Table of Content

The index of this document is generated using (GitHub Markdown ToC](https://github.com/ekalinin/github-markdown-toc). Run the following command to update the ToC

./gh-md-toc --insert --hide-footer README.md 

okta-auth0-android-challenge's People

Contributors

eaceto avatar

Watchers

 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.