1234567891011121314151617181920212223242526272829303132 |
- import * as Google from "expo-auth-session/providers/google";
- import { getData } from "../service/asyncStorage";
- import { ACCESS_TOKEN } from "../constants/localStorage";
- import { revokeAsync } from "expo-auth-session";
- import variables from "../utils/variables";
-
- const useAuthHook = () => {
- const [request, response, promptAsync] = Google.useAuthRequest({
- androidClientId: variables.androidClientId,
- iosClientId: variables.iosClientId,
- expoClientId: variables.expoClientId,
- });
-
- const logoutAuthProvider = async () => {
- const token = await getData(ACCESS_TOKEN);
- if (token !== null) {
- await revokeAsync(
- { token: token },
- { revocationEndpoint: variables.revocationEndpoint }
- );
- }
- };
-
- return {
- request,
- response,
- promptAsync,
- logoutAuthProvider,
- };
- };
-
- export default useAuthHook;
|