Google Sign-In SDK
The iOS app uses the Google Sign-In SDK for iOS. The SDK handles:- Presenting the native Google consent screen.
- Managing the OAuth authorization code exchange with Google’s servers.
- Returning an access token, optional refresh token, and token metadata to the app.
iOS OAuth credentials (client ID) are separate from server-side OAuth credentials. The iOS client ID is stored in AWS Secrets Manager under
Google-OAuth-Client-ID and is read by Lambda functions when they need to refresh tokens. No client secret exists for the iOS client; Google’s token endpoint accepts refresh requests from public clients without one.Native iOS OAuth flow
1
User initiates Gmail connection
The user taps the “Connect Gmail” button in the PayPulse app. The app calls
GIDSignIn.sharedInstance.signIn(...) with the gmail.readonly scope.2
Google consent screen
The Google Sign-In SDK opens a secure in-app browser session (ASWebAuthenticationSession) displaying Google’s consent screen. The user reviews the requested permissions and approves.
3
Tokens returned to the app
Google’s servers exchange the authorization code for tokens and return them to the SDK. The app receives an
access_token, a refresh_token (on first authorization), expires_in, and the granted scope.4
Tokens sent to backend
The app immediately sends the tokens to the backend via the store-tokens endpoint.
The /v1/auth/gmail-tokens endpoint
The iOS app posts token data to this endpoint immediately after the user grants consent. The request must include a valid PayPulse JWT in the Authorization header.
Method: POSTPath:
/v1/auth/gmail-tokensAuthentication: Bearer JWT (from PayPulse login)
Request body
request body
The endpoint also accepts
application/x-www-form-urlencoded bodies for compatibility.
Response
success response (201)
account_switch field is true when the user connects a different Google account than the one previously stored. The iOS app can use this to display a warning.
Gmail connection status in user profile
TheGET /v1/user/me endpoint returns a gmail_account_connected boolean field that reflects whether the user has OAuth tokens stored in Secrets Manager:
user profile response
gmail_account_connected to decide whether to show the “Connect Gmail” button or the connected Gmail address. The check is performed by looking up the secret gmail/user/{user_id} in Secrets Manager — if it exists, the account is considered connected.