Navigation

Google Authentication

Follow the directions in https://support.google.com/cloud/answer/6158849?hl=en to create OAuth client ID credentials for your application.

Application Required Google OAuth Credentials
Web Applications

OAuth for Web application type

For an example, see ToDo (Web App).

Android Applications
OAuth for Web application type (for MongoDB Stitch Authentication configuration) and
OAuth for Android application type (for SHA1 association only)

For an example, see ToDo (Android App).

Google OAuth Client ID for Web Application

A. Create OAuth client ID with the following configuration:

  • For Application Type, select Web application.

  • For Name, enter the name you want to associate with this application.

  • For Authorized JavaScript origins, enter the following:

    https://stitch.mongodb.com
    
  • For Authorized redirect URIs, enter the following:

    https://stitch.mongodb.com/api/client/v2.0/auth/callback
    

B. Once you have the Web client ID and secret, in the MongoDB Stitch console:

  1. Click Authentication. The page displays the Authentication Providers.
  2. For Google, click Edit.
  3. In the Edit Provider dialog,
    1. Switch Google to enabled.
    2. Enter your Client ID and Client Secret.
    3. For web applications, enter the Redirect URIs.
    4. Click Save.

See

ToDo (Web App) for an example.

Google OAuth Client ID For Android Applications

A. Create Google OAuth Client ID for Web Application.

Follow the procedure in Google OAuth Client ID for Web Application to create Google OAuth Client ID for Web Application and configure MongoDB Stitch Authentication with the Google OAuth Client ID and Secret.

B. Create OAuth client ID with the following configuration:

Note

The OAuth client ID for Android is used for SHA1 association only. To configure MongoDB Stitch authentication for the Android application, use the Google OAuth Client ID for Web Application created for the application.

  • For Application Type, select Android.

  • For Name, enter a name to associate with the app.

  • For Signing-certificate fingerprint, enter the SHA1 fingerprint. To generate the SHA1 fingerprint, run the following command in a terminal or Windows Command Prompt:

    keytool -exportcert -alias androiddebugkey -keystore <path to debug.keystore> -list -v
    

    Terminal example:

    keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore -list -v
    

    Windows Command Prompt example:

    keytool -exportcert -alias androiddebugkey -keystore %HOMEPATH%\.android\debug.keystore -list -v
    

    Tip

    If using debug.keystore, the password is android.

    Enter the SHA1 fingerprint. For more information and an example, see Google Setting up OAuth 2.0 Help page

  • Enter the package name for your project. The package name can be found in your application project’s AndroidManifest.xml file.

See

ToDo (Android App) for an example.