google auth issue
JavaScript
import React, { useState, useEffect } from "react";
import { StatusBar } from "expo-status-bar";
import { Button, StyleSheet, Text, View } from "react-native";
import { Camera } from "expo-camera";
import * as Google from "expo-google-app-auth";
import * as WebBrowser from "expo-web-browser";
WebBrowser.maybeCompleteAuthSession();
export default function App() {
const [token, setToken] = useState("");
const [userInfo, setUserInfo] = useState(null);
const [cameraPermission, setCameraPermission] = useState(false);
const [request, response, promptAsync] = Google.useAuthRequest({
responseType: "id_token",
androidClientId:
"",
iosClientId:
"",
});
// useEffect(() => {
// if (response?.type === "success") {
// setToken(response.authentication.accessToken);
// getUserInfo();
// }
// }, [response, token]);
// const getUserInfo = async () => {
// try {
// const response = await fetch(
// "https://www.googleapis.com/userinfo/v2/me",
// {
// headers: { Authorization: `Bearer ${token}` },
// }
// );
// const user = await response.json();
// setUserInfo(user);
// } catch (error) {
// console.log(error)
// }
// };
useEffect(() => {
const getCameraPermissionAsync = async () => {
const { status } = await Camera.requestCameraPermissionsAsync();
if (status === "granted") {
setCameraPermission(true);
}
if (status !== "granted") {
alert("Sorry, we need camera permissions to make this work!");
}
};
getCameraPermissionAsync();
}, []);
return (
<View style={{ flex: 1 }}>
{cameraPermission ? (
<View>
<Camera
style={{ flex: 1 }}
type={Camera.Constants.Type.back} // or Camera.Constants.Type.front
/>
<Text style={styles.logo}>PlaceHolder</Text>
<View style={styles.buttonContainer}>
...