| 123456789101112131415161718192021222324252627282930313233 |
- import React from "react";
- 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;
|