loginWithCode method

Future<AuthSuccess> loginWithCode(
  1. Session session, {
  2. required String code,
  3. required String codeVerifier,
  4. required String redirectUri,
  5. Transaction? transaction,
})

Validates a Google authorization code from the web OAuth2 PKCE flow and either logs in the associated user or creates a new account.

This is the web counterpart of login, which accepts an ID token directly (used on native platforms via the google_sign_in package).

If a new user is created an associated UserProfile is also created.

Implementation

Future<AuthSuccess> loginWithCode(
  final Session session, {
  required final String code,
  required final String codeVerifier,
  required final String redirectUri,
  final Transaction? transaction,
}) async {
  final tokens = await utils.exchangeCodeForToken(
    session,
    code: code,
    codeVerifier: codeVerifier,
    redirectUri: redirectUri,
  );

  return login(
    session,
    idToken: tokens.idToken,
    accessToken: tokens.accessToken,
    transaction: transaction,
  );
}