Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

useAuthHook.js 889B

123456789101112131415161718192021222324252627282930313233
  1. import React from "react";
  2. import * as Google from "expo-auth-session/providers/google";
  3. import { getData } from "../service/asyncStorage";
  4. import { ACCESS_TOKEN } from "../constants/localStorage";
  5. import { revokeAsync } from "expo-auth-session";
  6. import variables from "../utils/variables";
  7. const useAuthHook = () => {
  8. const [request, response, promptAsync] = Google.useAuthRequest({
  9. androidClientId: variables.androidClientId,
  10. iosClientId: variables.iosClientId,
  11. expoClientId: variables.expoClientId,
  12. });
  13. const logoutAuthProvider = async () => {
  14. const token = await getData(ACCESS_TOKEN);
  15. if (token !== null) {
  16. await revokeAsync(
  17. { token: token },
  18. { revocationEndpoint: variables.revocationEndpoint }
  19. );
  20. }
  21. };
  22. return {
  23. request,
  24. response,
  25. promptAsync,
  26. logoutAuthProvider,
  27. };
  28. };
  29. export default useAuthHook;