You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

useAuthHook.js 862B

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