Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unacceptable audience in id_token: GoogleSignIn library #221

Open
ActuallyTaylor opened this issue Jan 18, 2024 · 2 comments
Open

Unacceptable audience in id_token: GoogleSignIn library #221

ActuallyTaylor opened this issue Jan 18, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@ActuallyTaylor
Copy link

ActuallyTaylor commented Jan 18, 2024

Bug report

Describe the bug

I have implemented the GoogleSignIn library for my application to retrieve data from the user's Gmail account. I would like to continue using the GoogleSignIn library in my app, but I also want to implement Supabase google authentication. Whenever I go to sign in the user using their idToken and accessToken I get the following error:

Unacceptable audience in id_token Auth.AuthError.api(Auth.AuthError.APIError(msg: nil, code: nil, error: Optional("invalid request"), errorDescription: Optional("Unacceptable audience in id_token"), weakPassword: nil))

I have checked my Supabase console and I am placing my iOS app's bundle ID into "Authorized Client IDs" which seems to only be for Android. Do I need to place this into the ClientID? If so what would my secret be in this situation.

Additional context

I have the following code (condensed) which authenticates the user first with GoogleSignIn. It then takes the user object and takes the idToken as well accessToken and provides them to Supabase's signInWithIdToken function.

let result = try await GIDSignIn.sharedInstance.signIn(withPresenting: window, hint: nil)
        
let user = result.user

guard let idToken = user.idToken?.tokenString else {
	return
}

try await supabase.auth.signInWithIdToken(
    credentials: .init(
        provider: .google,
        idToken: idToken,
        accessToken: user.accessToken.tokenString
    )
)
@ActuallyTaylor ActuallyTaylor added the bug Something isn't working label Jan 18, 2024
@grdsdev
Copy link
Collaborator

grdsdev commented May 23, 2024

Hi @ActuallyTaylor we have a new guide for Google Sign-In, can you check it?

@dshukertjr
Copy link
Member

@ActuallyTaylor The error most likely means that you didn't set the web client ID in your Supabase dashboard. Google uses web client ID to verify the token instead of the iOS client ID, so although you do need to create the iOS client ID as well, you do need to create the web client ID in addition to it, add it your application and add it to the Supabase dashboard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants