35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
import * as React from 'react';
|
|
import * as WebBrowser from 'expo-web-browser';
|
|
import * as Google from 'expo-auth-session/providers/google';
|
|
import { Button } from 'react-native';
|
|
import {createContext, useState} from "react";
|
|
|
|
WebBrowser.maybeCompleteAuthSession();
|
|
|
|
export default function AuthScreen({authCallback} ) {
|
|
const [request, response, promptAsync] = Google.useAuthRequest({
|
|
expoClientId: '61386079886-2k3g6793pgt5pha4rhdojpvgrkuccfj7.apps.googleusercontent.com',
|
|
iosClientId: '61386079886-2k3g6793pgt5pha4rhdojpvgrkuccfj7.apps.googleusercontent.com',
|
|
androidClientId: '61386079886-2k3g6793pgt5pha4rhdojpvgrkuccfj7.apps.googleusercontent.com',
|
|
webClientId: '61386079886-2k3g6793pgt5pha4rhdojpvgrkuccfj7.apps.googleusercontent.com',
|
|
});
|
|
const AuthContext = useState()
|
|
React.useEffect(() => {
|
|
if (response?.type === 'success') {
|
|
const { authentication } = response;
|
|
// @ts-ignore
|
|
authCallback(authentication)
|
|
}
|
|
}, [response]);
|
|
|
|
return (
|
|
<Button
|
|
disabled={!request}
|
|
title="Login"
|
|
onPress={() => {
|
|
promptAsync();
|
|
}}
|
|
/>
|
|
);
|
|
}
|