diff --git a/app.json b/app.json
index d8e36a6e..dbdf8cd3 100644
--- a/app.json
+++ b/app.json
@@ -12,11 +12,16 @@
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
- "assetBundlePatterns": ["**/*"],
+ "assetBundlePatterns": [
+ "**/*"
+ ],
"ios": {
- "supportsTablet": true
+ "supportsTablet": true,
+ "usesAppleSignIn": true,
+ "googleServicesFile": "./GoogleService-Info.plist",
},
"android": {
+ "googleServicesFile": "./google-services.json",
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#ffffff"
@@ -25,6 +30,9 @@
"web": {
"favicon": "./assets/favicon.png"
},
- "plugins": ["expo-router"]
+ "plugins": [
+ "expo-router",
+ "@react-native-google-signin/google-signin",
+ ]
}
}
diff --git a/package-lock.json b/package-lock.json
index 9729e22f..9c6cd582 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -11,6 +11,7 @@
"@expo/vector-icons": "^13.0.0",
"@react-native-async-storage/async-storage": "1.18.2",
"@react-native-community/datetimepicker": "7.2.0",
+ "@react-native-google-signin/google-signin": "^10.0.1",
"@react-navigation/bottom-tabs": "^6.5.9",
"@react-navigation/material-bottom-tabs": "^6.2.17",
"@react-navigation/native": "^6.1.8",
@@ -6277,6 +6278,21 @@
"invariant": "^2.2.4"
}
},
+ "node_modules/@react-native-google-signin/google-signin": {
+ "version": "10.0.1",
+ "resolved": "https://registry.npmjs.org/@react-native-google-signin/google-signin/-/google-signin-10.0.1.tgz",
+ "integrity": "sha512-oZoU2lfKyn0s0GqqdFsi4v2FSENrxQYQU9DD/RSkxDdkIQ49Wwo6p5LKlgXY04GwZEVdYMuvZN3G89gQW0ig2g==",
+ "peerDependencies": {
+ "expo": ">=47.0.0",
+ "react": "*",
+ "react-native": "*"
+ },
+ "peerDependenciesMeta": {
+ "expo": {
+ "optional": true
+ }
+ }
+ },
"node_modules/@react-native/assets-registry": {
"version": "0.72.0",
"resolved": "https://registry.npmjs.org/@react-native/assets-registry/-/assets-registry-0.72.0.tgz",
diff --git a/package.json b/package.json
index 4ff89622..8285f228 100644
--- a/package.json
+++ b/package.json
@@ -15,6 +15,7 @@
"@expo/vector-icons": "^13.0.0",
"@react-native-async-storage/async-storage": "1.18.2",
"@react-native-community/datetimepicker": "7.2.0",
+ "@react-native-google-signin/google-signin": "^10.0.1",
"@react-navigation/bottom-tabs": "^6.5.9",
"@react-navigation/material-bottom-tabs": "^6.2.17",
"@react-navigation/native": "^6.1.8",
@@ -25,6 +26,7 @@
"deprecated-react-native-prop-types": "^4.2.1",
"dom-parser": "^0.1.6",
"expo": "~49.0.11",
+ "expo-apple-authentication": "~6.1.0",
"expo-constants": "~14.4.2",
"expo-linking": "~5.0.2",
"expo-router": "^2.0.0",
@@ -40,13 +42,10 @@
"react-native-render-html": "^6.3.4",
"react-native-root-siblings": "^4.1.1",
"react-native-root-toast": "^3.5.1",
- "react-native-ionicons": "^4.6.5",
- "react-native-elements": "^3.4.3",
"react-native-safe-area-context": "4.6.3",
"react-native-screens": "~3.22.0",
- "react-native-vector-icons": "^10.0.0",
"react-native-url-polyfill": "^2.0.0",
- "expo-apple-authentication": "~6.1.0"
+ "react-native-vector-icons": "^10.0.0"
},
"devDependencies": {
"@babel/core": "^7.20.0",
diff --git a/src/app/auth/login.tsx b/src/app/auth/login.tsx
index 4015aabd..ffab1e6e 100644
--- a/src/app/auth/login.tsx
+++ b/src/app/auth/login.tsx
@@ -1,9 +1,11 @@
import React, { useState } from 'react';
import { Redirect, Link } from 'expo-router';
-import { Alert, View } from 'react-native';
+import { Alert, View, Text } from 'react-native';
import { Button, Input } from 'react-native-elements';
import { useSession } from '../../utils/AuthContext';
import globalStyles from '../../styles/globalStyles';
+import AppleAuth from '../../components/AppleAuth';
+import GoogleAuth from '../../components/GoogleAuth';
function LoginScreen() {
const sessionHandler = useSession();
@@ -50,11 +52,13 @@ function LoginScreen() {
/>
- Don't have an account? Sign Up
-
+ Don't have an account? Sign Up
+ OR
+
+
);
}
diff --git a/src/components/AppleAuth.tsx b/src/components/AppleAuth.tsx
index a00ef50f..1ddb065d 100644
--- a/src/components/AppleAuth.tsx
+++ b/src/components/AppleAuth.tsx
@@ -3,7 +3,7 @@ import * as AppleAuthentication from 'expo-apple-authentication';
import { useSession } from '../utils/AuthContext';
import { router } from 'expo-router';
-export function Auth() {
+export default function AppleAuth() {
const { signInWithApple } = useSession();
if (Platform.OS === 'ios')
return (
diff --git a/src/components/GoogleAuth.tsx b/src/components/GoogleAuth.tsx
new file mode 100644
index 00000000..54bc06e1
--- /dev/null
+++ b/src/components/GoogleAuth.tsx
@@ -0,0 +1,45 @@
+import {
+ GoogleSignin,
+ GoogleSigninButton,
+ statusCodes,
+} from '@react-native-google-signin/google-signin';
+import { useSession } from '../utils/AuthContext';
+
+export default function GoogleAuth() {
+ const { signInWithGoogle } = useSession();
+ GoogleSignin.configure({
+ scopes: ['https://www.googleapis.com/auth/drive.readonly'],
+ webClientId: 'YOUR CLIENT ID FROM GOOGLE CONSOLE',
+ });
+
+ return (
+ {
+ try {
+ await GoogleSignin.hasPlayServices();
+ const userInfo = await GoogleSignin.signIn();
+ if (userInfo.idToken) {
+ const { data, error } = await signInWithGoogle(userInfo.idToken);
+ console.log(error, data);
+ } else {
+ throw new Error('no ID token present!');
+ }
+ } catch (error: any) {
+ if (error) {
+ if (error.code === statusCodes.SIGN_IN_CANCELLED) {
+ // user cancelled the login flow
+ } else if (error.code === statusCodes.IN_PROGRESS) {
+ // operation (e.g. sign in) is in progress already
+ } else if (error.code === statusCodes.PLAY_SERVICES_NOT_AVAILABLE) {
+ // play services not available or outdated
+ } else {
+ // some other error happened
+ }
+ }
+ }
+ }}
+ />
+ );
+}
diff --git a/src/utils/AuthContext.tsx b/src/utils/AuthContext.tsx
index 9c4a09ad..9c05f002 100644
--- a/src/utils/AuthContext.tsx
+++ b/src/utils/AuthContext.tsx
@@ -15,6 +15,7 @@ export interface AuthState {
signUp: (email: string, password: string) => Promise;
signInWithEmail: (email: string, password: string) => Promise;
signInWithApple: (token: string) => Promise;
+ signInWithGoogle: (token: string) => Promise;
signOut: () => void;
}
@@ -71,12 +72,17 @@ export function AuthContextProvider({
setSession(null);
};
- const signInWithApple = (token: string) =>
+ const signInWithApple = (token: string) =>
supabase.auth.signInWithIdToken({
- provider: 'apple',
- token: token
- });
+ provider: 'apple',
+ token: token,
+ });
+ const signInWithGoogle = async (token: string) =>
+ await supabase.auth.signInWithIdToken({
+ provider: 'google',
+ token: token,
+ });
const authContextValue = useMemo(
() => ({
@@ -85,6 +91,7 @@ export function AuthContextProvider({
signIn,
signInWithEmail,
signInWithApple,
+ signInWithGoogle,
signOut,
}),
[session],