Skip to content

feat(android): forward nonce to native login for OIDC id token - #494

Merged
darwin-morocho merged 2 commits into
darwin-morocho:masterfrom
spydon:feat/android-oidc-nonce
Jul 3, 2026
Merged

feat(android): forward nonce to native login for OIDC id token#494
darwin-morocho merged 2 commits into
darwin-morocho:masterfrom
spydon:feat/android-oidc-nonce

Conversation

@spydon

@spydon spydon commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

What

On Android, forward the nonce into LoginConfiguration and surface the returned AuthenticationToken (OIDC id token) on the result. iOS already exposes the AuthenticationToken; Android was ignoring it, so ClassicToken.authenticationToken was always null there.

Changes

  • FacebookAuth.login reads the nonce argument and, when present, logs in with a LoginConfiguration(permissions, nonce) so the SDK requests an OIDC id token.
  • FacebookLoginResultDelegate.onSuccess extracts loginResult.getAuthenticationToken() and includes it in the response.
  • FlutterFacebookAuthPlugin passes the nonce argument through the method channel.

Why

Consumers that verify an OIDC id token (for example Supabase's signInWithIdToken) need the AuthenticationToken. This makes the Android side able to return it, matching iOS.

Note on Android behavior

Facebook's Limited Login (the OIDC id token flow) is documented as iOS-only. On Android, Facebook mints the AuthenticationToken only on a full (first) authorization; repeat native logins return a classic access token with a null AuthenticationToken, and there is no SDK-side way to force it (see facebook/facebook-android-sdk#1132). So this PR reliably surfaces the id token on iOS and on the first Android authorization, which is all Facebook exposes. It does not, and cannot, guarantee an id token on every Android login. That's a Facebook platform limitation, not something the plugin can work around.

The Android side ignored the nonce argument and always called
loginManager.logIn(activity, permissions), so no OIDC AuthenticationToken
was requested and ClassicToken.authenticationToken was null on native
(non-webOnly) login. When a nonce is provided, build a LoginConfiguration
with it so the Facebook Android SDK returns an id token, and read that
token from the login result.
@blocksorg

blocksorg Bot commented Jul 1, 2026

Copy link
Copy Markdown

Mention Blocks like a regular teammate with your question or request:

@blocks review this pull request
@blocks make the following changes ...
@blocks create an issue from what was mentioned in the following comment ...
@blocks explain the following code ...
@blocks are there any security or performance concerns?

Run @blocks /help for more information.

Workspace settings | Disable this message

@spydon
spydon marked this pull request as ready for review July 2, 2026 08:39
@spydon
spydon marked this pull request as draft July 2, 2026 09:16
@spydon
spydon force-pushed the feat/android-oidc-nonce branch from 845c66b to 106fbd2 Compare July 3, 2026 07:39
@spydon
spydon marked this pull request as ready for review July 3, 2026 07:39
@darwin-morocho

Copy link
Copy Markdown
Owner

@spydon on it

@darwin-morocho
darwin-morocho merged commit e880a01 into darwin-morocho:master Jul 3, 2026
3 checks passed
@darwin-morocho

Copy link
Copy Markdown
Owner

@spydon thanks for your PR

@spydon
spydon deleted the feat/android-oidc-nonce branch July 3, 2026 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants