This commit is contained in:
2025-09-05 17:00:23 +02:00
parent 17391daa76
commit 308d301912
2 changed files with 28 additions and 16 deletions
+10 -6
View File
@@ -3,7 +3,7 @@ import * as AuthSession from "expo-auth-session";
import * as GoogleAuth from "expo-auth-session/providers/google";
import * as WebBrowser from "expo-web-browser";
import React, { useEffect, useState } from "react";
import { Platform, Pressable, Text, View } from "react-native";
import { Pressable, Text, View } from "react-native";
import { useGlobal } from "reactn";
import { background } from "../assets";
import GradientButton from "../components/GradientButton.js";
@@ -106,13 +106,15 @@ export default ({ navigation }) => {
if (!idToken) {
// Otherwise, exchange the authorization code for tokens using PKCE.
const code = response?.params?.code || response?.authentication?.code;
const code =
response?.params?.code || response?.authentication?.code;
if (!code) throw new Error("Code d'autorisation Google manquant");
// Use the exact clientId used during the authorize request.
const clientId = request?.clientId;
const discovery = {
authorizationEndpoint: "https://accounts.google.com/o/oauth2/v2/auth",
authorizationEndpoint:
"https://accounts.google.com/o/oauth2/v2/auth",
tokenEndpoint: "https://oauth2.googleapis.com/token",
revocationEndpoint: "https://oauth2.googleapis.com/revoke",
};
@@ -136,9 +138,11 @@ export default ({ navigation }) => {
idToken = tokenResponse?.id_token;
}
if (!idToken) throw new Error("Jeton Google manquant (échange/retour)");
if (!idToken)
throw new Error("Jeton Google manquant (échange/retour)");
const credential = firebase.auth.GoogleAuthProvider.credential(idToken);
const credential =
firebase.auth.GoogleAuthProvider.credential(idToken);
await firebase.auth().signInWithCredential(credential);
await afterLoginNavigate();
}
@@ -167,7 +171,7 @@ export default ({ navigation }) => {
hideBackButton
>
<View style={{ flex: 1, paddingTop: 20 }}>
<ItemContainer height={490}>
<ItemContainer height={600}>
<View style={{ gap: 30, paddingTop: 5, paddingHorizontal: 5 }}>
<View style={{ gap: 2 }}>
<Text