> For the complete documentation index, see [llms.txt](https://eduardo-jaramillo.gitbook.io/google-oauth2/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://eduardo-jaramillo.gitbook.io/google-oauth2/master.md).

# Google OAuth 2.0 in AppGyver

## Introduction

This tutorial covers the authorization for Firestore

## Basic steps common to Firestore and Photos

Detailed information can be found in [Google Identity Platform](https://developers.google.com/identity/protocols/oauth2)

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 ](https://console.developers.google.com/apis)and select your Firestore data base.&#x20;

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.&#x20;

{% hint style="warning" %}
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.
{% endhint %}

### 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.
