mirror of
https://github.com/mudabbir-ahmad/Media-Aggregation-and-Sorting-System.git
synced 2026-10-08 03:40:20 +00:00
2.6 KiB
2.6 KiB
Google OAuth Setup for Android APK
Step 1: Create a Google Cloud Project
- Go to https://console.cloud.google.com/
- Click Select a project → New Project
- Name it and click Create
Step 2: Enable the Photos Library API
- Go to APIs & Services → Library
- Search for Photos Library API → Enable it
- ⚠️ This step is required — without it, all Photos API calls return 403
Step 3: Configure the OAuth Consent Screen
- Go to APIs & Services → OAuth consent screen
- Choose External → Create
- Fill in:
- App name: MASS Photo App
- User support email: your email
- Developer contact: your email
- Scopes → Add or Remove Scopes → add these:
openidhttps://www.googleapis.com/auth/photoslibraryhttps://www.googleapis.com/auth/userinfo.emailhttps://www.googleapis.com/auth/userinfo.profile
- Test users → Add your Google account email address
- ⚠️ This is critical — if your email is not listed as a test user, Google will silently strip the Photos scope from the granted token, causing a 403 "insufficient authentication scopes" error.
Step 4: Create an Android OAuth Client ID
- Go to APIs & Services → Credentials
- + Create Credentials → OAuth client ID
- Application type: Android
- Package name:
com.bobthebob.massphotoapp - SHA-1 certificate fingerprint: get it by running
eas credentials --platform android - Click Create and copy the Client ID
- Open
src/AUTH/GoogleAUTH.jsand setANDROID_CLIENT_IDto the copied value
How it works
- The Android client ID is used for both the authorization request and the token exchange. Google verifies the request using the app's package name + SHA-1 signing certificate, so no redirect URI registration is needed.
- The redirect goes to
com.bobthebob.massphotoapp:/oauthredirectwhich Android routes back into the app via the intent filter inapp.json. - Android clients are public (no
client_secretrequired). PKCEcode_verifieris used to secure the authorization code exchange.
Testing the API with OAuth Playground
- Go to https://developers.google.com/oauthplayground
- Click the gear icon → check "Use your own OAuth credentials"
- You will need a Web application client for the playground only (the
playground cannot use Android clients). Create one in the console if needed,
add
https://developers.google.com/oauthplaygroundto its redirect URIs. - Select Photos Library API scopes and authorize
- Copy the access token and run:
node TEST/testGooglePhotosAPI.js <TOKEN>