Git Product home page Git Product logo

firebase-auth-with-huawei-id's Introduction

Firebase Auth with Huawei ID

Firebase Auth

Introduction

In this repo contains that sample to use custom auth tokens to Sign In Firebase with Huawei ID.

As is known, Firebase Auth is a GMS dependent service, so it cannot work on non-GMS devices. Instead, we will use Firebase Auth Rest API.

I used heroku as a backend server but instead, also you can use Firebase Cloud Functions, HMS Cloud Functions or your own backend server.

You can see flow at the below.

Flow

1. Request Authorization Code
Send an authorization request to Huawei Account Server and start login flow.
2. Obtain ID Token
After sign-in authorization is successfully , call the HuaweiAuthManager.parseAuthResultFromIntent method of onActivityResult and obtain ID Token, display name, profile picture etc.
3. Verify ID Token (Optional*)
This is an optional step. If you want, you can verify user ID token locally on client or verify on Huawei server on your backend.

Verify ID Token

4. Get user or create new user
Bring the user from Firebase according to the uid or create a new user.
5. Create Firebase Auth Custom Token
Create custom token using the Firebase Admin SDK on your backend server.

Firebase Custom Tokens

6. Login with custom token using Firebase Auth
Exchange custom token for an ID and refresh token.

Firebase Auth Rest Custom Token

Setup

AppGallery & Android

  • Enable Account Kit
  • Add agconnect-services.json into the your android project. ( android\app )

Firebase & Android

  • Enable Firebase Auth
  • Configure Firebase Admin SDK and add it into your server project.
  • Add serviceAccountKey.json into the your server project. ( heroku_server )
  • Add google-services.json into the your android project. ( android\app )
  • Configure WEB <API_KEY>.(android\app\src\main\java\com\ekrmh\firebasehuaweiauth\util\NetworkSingleton.kt)

Backend & Android

  • Configure <DATABASE_URL> (heroku_server/index.js)
  • Configure your server url. <YOUR_SERVER_URL> (android\app\src\main\java\com\ekrmh\firebasehuaweiauth\util\NetworkSingleton.kt)

Author

Ekrem Hatipoglu [email protected]

If you encounter any problems, you can always contact me.

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.