Google OAuth 2.0 in AppGyver

Tutorial

Introduction

This tutorial covers the authorization for Firestore

Basic steps common to Firestore and Photos

Detailed information can be found in Google Identity Platform

  1. Obtain OAuth credentials in Google API Console

  2. Obtain the access token from the Google authorization server

  3. Verify the scopes granted

  4. Send the access token to the API

  5. Refresh the access token

Google FIRESTORE OAuth 2.0

Enable authentication on AppGyver

Google API console and credentials

Select the database on the console and obtain the OAuth credentials

Go to the console and select your Firestore data base.

Then select Credentials. There you will find the API key (the one you will pass with key=API_KEY parameter) and client ID. The API key can be further configured to restrict access, so it can be only used by specific web sites, IP addresses or apps.

It is strongly recommended to restrict the database access so you prevent unauthorized use. This can be done later, once you have the authorization working for your app.

Access token

The access token grants access to the APIs and the scopes of the access

App Login

To login, an application variable type object has to be created so contain the email, password an return token flag

The user has to enter the values for email and password, and the value for the return token flag has to be set to "true"

A http request has to be set, with a POST call to https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key={your database API key}. The request body is the object that contains the email and password

The response from the http request has to be assigned to a applicaton variable type object, with properties to match the Firestore response to the call: localId, email, displayName, idToken, registred, refreshToken, expiresIn. The binding has to be made by formulas, typing the properties names by hand.

Last updated