redirect_uri_mismatch on React native expo

173 views Asked by At

Getting the error below clicking details just shows Error 400: redirect_uri_mismatch

Here's my code:

import React, { createContext, useContext } from 'react';
import * as Google from 'expo-auth-session/providers/google';
import * as WebBrowser from 'expo-web-browser';

WebBrowser.maybeCompleteAuthSession();

const AuthContext = createContext({});

export const AuthProvider = ({ children }) => {
  
  const [request, response, promptAsync] = Google.useAuthRequest({
    androidClientId: "redacted",
    iosClientId: "redacted",
    expoClientId: "redacted",
    redirectUri: "redacted"
  });

  const signInWithGoogle = async () => {
    try {
      console.log("Auth Request:", request);
      console.log("Auth Response:", response);
      await promptAsync(); // Wait for the authentication prompt

      // Additional logic after authentication
      // For example, you can fetch user data here

    } catch (error) {
      console.error("Error during Google sign-in:", error);
    }
  };

  return (
    <AuthContext.Provider 
        value={{
            user: null,
            signInWithGoogle: signInWithGoogle,
        }}
    >
        {children}
    </AuthContext.Provider>
  );
};

export default function useAuth() {
  return useContext(AuthContext);
}

I've correctly set up a redirect uri in google console matching the one in the request but still getting the same error

0

There are 0 answers