Skip to content

Commit 2081669

Browse files
committed
Funky sign in with google
1 parent d061686 commit 2081669

File tree

7 files changed

+110
-20
lines changed

7 files changed

+110
-20
lines changed

apps/WarriorHappy/app.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"expo": {
33
"name": "WarriorHappy",
44
"slug": "WarriorHappy",
5-
"version": "3.2.6",
5+
"version": "3.2.8",
66
"orientation": "portrait",
77
"icon": "./assets/images/icon.png",
88
"scheme": "myapp",

apps/WarriorHappy/ios/Podfile.lock

+37
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
PODS:
2+
- AppAuth (1.6.2):
3+
- AppAuth/Core (= 1.6.2)
4+
- AppAuth/ExternalUserAgent (= 1.6.2)
5+
- AppAuth/Core (1.6.2)
6+
- AppAuth/ExternalUserAgent (1.6.2):
7+
- AppAuth/Core
28
- boost (1.83.0)
39
- DoubleConversion (1.1.6)
410
- EXConstants (15.4.5):
@@ -7,6 +13,10 @@ PODS:
713
- ExpoModulesCore
814
- Expo (50.0.7):
915
- ExpoModulesCore
16+
- ExpoAdapterGoogleSignIn (11.0.0):
17+
- ExpoModulesCore
18+
- GoogleSignIn (~> 7.0)
19+
- React-Core
1020
- ExpoAppleAuthentication (6.3.0):
1121
- ExpoModulesCore
1222
- ExpoCrypto (12.8.1):
@@ -51,6 +61,14 @@ PODS:
5161
- ReactCommon/turbomodule/core (= 0.73.4)
5262
- fmt (6.2.1)
5363
- glog (0.3.5)
64+
- GoogleSignIn (7.0.0):
65+
- AppAuth (~> 1.5)
66+
- GTMAppAuth (< 3.0, >= 1.3)
67+
- GTMSessionFetcher/Core (< 4.0, >= 1.1)
68+
- GTMAppAuth (2.0.0):
69+
- AppAuth/Core (~> 1.6)
70+
- GTMSessionFetcher/Core (< 4.0, >= 1.5)
71+
- GTMSessionFetcher/Core (3.3.1)
5472
- hermes-engine (0.73.4):
5573
- hermes-engine/Pre-built (= 0.73.4)
5674
- hermes-engine/Pre-built (0.73.4)
@@ -1120,6 +1138,9 @@ PODS:
11201138
- React-Core
11211139
- RNFlashList (1.6.3):
11221140
- React-Core
1141+
- RNGoogleSignin (11.0.0):
1142+
- GoogleSignIn (~> 7.0)
1143+
- React-Core
11231144
- RNReanimated (3.7.1):
11241145
- glog
11251146
- RCT-Folly (= 2022.05.16.00)
@@ -1151,6 +1172,7 @@ DEPENDENCIES:
11511172
- EXConstants (from `../../../node_modules/expo-constants/ios`)
11521173
- EXFont (from `../../../node_modules/expo-font/ios`)
11531174
- Expo (from `../../../node_modules/expo`)
1175+
- "ExpoAdapterGoogleSignIn (from `../../../node_modules/@react-native-google-signin/google-signin/expo/ios`)"
11541176
- ExpoAppleAuthentication (from `../../../node_modules/expo-apple-authentication/ios`)
11551177
- ExpoCrypto (from `../../../node_modules/expo-crypto/ios`)
11561178
- ExpoFileSystem (from `../../../node_modules/expo-file-system/ios`)
@@ -1213,14 +1235,19 @@ DEPENDENCIES:
12131235
- ReactCommon/turbomodule/core (from `../../../node_modules/react-native/ReactCommon`)
12141236
- "RNCAsyncStorage (from `../../../node_modules/@react-native-async-storage/async-storage`)"
12151237
- "RNFlashList (from `../../../node_modules/@shopify/flash-list`)"
1238+
- "RNGoogleSignin (from `../../../node_modules/@react-native-google-signin/google-signin`)"
12161239
- RNReanimated (from `../../../node_modules/react-native-reanimated`)
12171240
- RNScreens (from `../../../node_modules/react-native-screens`)
12181241
- RNSVG (from `../../../node_modules/react-native-svg`)
12191242
- Yoga (from `../../../node_modules/react-native/ReactCommon/yoga`)
12201243

12211244
SPEC REPOS:
12221245
trunk:
1246+
- AppAuth
12231247
- fmt
1248+
- GoogleSignIn
1249+
- GTMAppAuth
1250+
- GTMSessionFetcher
12241251
- libaom
12251252
- libavif
12261253
- libevent
@@ -1243,6 +1270,8 @@ EXTERNAL SOURCES:
12431270
:path: "../../../node_modules/expo-font/ios"
12441271
Expo:
12451272
:path: "../../../node_modules/expo"
1273+
ExpoAdapterGoogleSignIn:
1274+
:path: "../../../node_modules/@react-native-google-signin/google-signin/expo/ios"
12461275
ExpoAppleAuthentication:
12471276
:path: "../../../node_modules/expo-apple-authentication/ios"
12481277
ExpoCrypto:
@@ -1362,6 +1391,8 @@ EXTERNAL SOURCES:
13621391
:path: "../../../node_modules/@react-native-async-storage/async-storage"
13631392
RNFlashList:
13641393
:path: "../../../node_modules/@shopify/flash-list"
1394+
RNGoogleSignin:
1395+
:path: "../../../node_modules/@react-native-google-signin/google-signin"
13651396
RNReanimated:
13661397
:path: "../../../node_modules/react-native-reanimated"
13671398
RNScreens:
@@ -1372,11 +1403,13 @@ EXTERNAL SOURCES:
13721403
:path: "../../../node_modules/react-native/ReactCommon/yoga"
13731404

13741405
SPEC CHECKSUMS:
1406+
AppAuth: 3bb1d1cd9340bd09f5ed189fb00b1cc28e1e8570
13751407
boost: d3f49c53809116a5d38da093a8aa78bf551aed09
13761408
DoubleConversion: fea03f2699887d960129cc54bba7e52542b6f953
13771409
EXConstants: 988aa430ca0f76b43cd46b66e7fae3287f9cc2fc
13781410
EXFont: f20669cb266ef48b004f1eb1f2b20db96cd1df9f
13791411
Expo: 1cf3922a9b26262b2556544d4defcecccd37d033
1412+
ExpoAdapterGoogleSignIn: ee39be2723cc5a39b3c01cb56d779831c975e17f
13801413
ExpoAppleAuthentication: 4fc9972356977f009911f2f3a5f56319c2a5b11b
13811414
ExpoCrypto: b6428f48599c007676dc81a9b5f72c07e62fdccc
13821415
ExpoFileSystem: a9273932e69a9a1e1a8d01b6ba895bb8294bbea2
@@ -1392,6 +1425,9 @@ SPEC CHECKSUMS:
13921425
FBReactNativeSpec: b5983e1ab92f2a059a712ab9267d661d8d0d9158
13931426
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
13941427
glog: c5d68082e772fa1c511173d6b30a9de2c05a69a2
1428+
GoogleSignIn: b232380cf495a429b8095d3178a8d5855b42e842
1429+
GTMAppAuth: 99fb010047ba3973b7026e45393f51f27ab965ae
1430+
GTMSessionFetcher: 8a1b34ad97ebe6f909fb8b9b77fba99943007556
13951431
hermes-engine: b2669ce35fc4ac14f523b307aff8896799829fe2
13961432
libaom: 144606b1da4b5915a1054383c3a4459ccdb3c661
13971433
libavif: 84bbb62fb232c3018d6f1bab79beea87e35de7b7
@@ -1442,6 +1478,7 @@ SPEC CHECKSUMS:
14421478
ReactCommon: dcc65c813041388dead6c8b477444757425ce961
14431479
RNCAsyncStorage: 618d03a5f52fbccb3d7010076bc54712844c18ef
14441480
RNFlashList: 4b4b6b093afc0df60ae08f9cbf6ccd4c836c667a
1481+
RNGoogleSignin: fc408799f1990a12497a32f64280c0fe353ffcc1
14451482
RNReanimated: 68be24ba590b9136af90698bb01527387c8061da
14461483
RNScreens: 2b73f5eb2ac5d94fbd61fa4be0bfebd345716825
14471484
RNSVG: ba3e7232f45e34b7b47e74472386cf4e1a676d0a

apps/WarriorHappy/ios/WarriorHappy.xcodeproj/project.pbxproj

+4
Original file line numberDiff line numberDiff line change
@@ -288,11 +288,15 @@
288288
inputPaths = (
289289
"${PODS_ROOT}/Target Support Files/Pods-WarriorHappy/Pods-WarriorHappy-resources.sh",
290290
"${PODS_CONFIGURATION_BUILD_DIR}/EXConstants/EXConstants.bundle",
291+
"${PODS_CONFIGURATION_BUILD_DIR}/GTMSessionFetcher/GTMSessionFetcher_Core_Privacy.bundle",
292+
"${PODS_CONFIGURATION_BUILD_DIR}/GoogleSignIn/GoogleSignIn.bundle",
291293
"${PODS_CONFIGURATION_BUILD_DIR}/React-Core/RCTI18nStrings.bundle",
292294
);
293295
name = "[CP] Copy Pods Resources";
294296
outputPaths = (
295297
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/EXConstants.bundle",
298+
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/GTMSessionFetcher_Core_Privacy.bundle",
299+
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/GoogleSignIn.bundle",
296300
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/RCTI18nStrings.bundle",
297301
);
298302
runOnlyForDeploymentPostprocessing = 0;

apps/WarriorHappy/ios/WarriorHappy/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<key>CFBundlePackageType</key>
2222
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
2323
<key>CFBundleShortVersionString</key>
24-
<string>3.2.6</string>
24+
<string>3.2.8</string>
2525
<key>CFBundleSignature</key>
2626
<string>????</string>
2727
<key>CFBundleURLTypes</key>

apps/WarriorHappy/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "warriorhappy",
33
"main": "index.ts",
4-
"version": "3.2.6",
4+
"version": "3.2.8",
55
"scripts": {
66
"start": "expo start",
77
"android": "expo run:android",
@@ -18,6 +18,7 @@
1818
"@expo/metro-runtime": "~3.1.3",
1919
"@expo/vector-icons": "^14.0.0",
2020
"@react-native-async-storage/async-storage": "1.21.0",
21+
"@react-native-google-signin/google-signin": "^11.0.0",
2122
"@react-navigation/native": "^6.0.2",
2223
"@shopify/flash-list": "1.6.3",
2324
"@supabase/auth-helpers-react": "^0.4.2",

apps/WarriorHappy/src/app/profile.tsx

+47-17
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ import {
99
} from "react-native";
1010
import * as AppleAuthentication from "expo-apple-authentication";
1111
import { AntDesign } from "@expo/vector-icons";
12+
import {
13+
GoogleSignin,
14+
GoogleSigninButton,
15+
statusCodes,
16+
} from "@react-native-google-signin/google-signin";
1217
import { Session, User } from "@supabase/supabase-js";
1318

1419
import { initiateAppleSignIn } from "../utils/auth";
@@ -52,7 +57,48 @@ export default function Profile() {
5257
</View>
5358
);
5459
}
60+
function GoogleSignIn() {
61+
GoogleSignin.configure({
62+
scopes: ["https://www.googleapis.com/auth/userinfo.email"],
63+
webClientId:
64+
"439665504915-55me8e9me7evlcjsldvpnug8jriok7dh.apps.googleusercontent.com",
65+
});
5566

67+
return (
68+
<GoogleSigninButton
69+
size={GoogleSigninButton.Size.Wide}
70+
color={GoogleSigninButton.Color.Dark}
71+
onPress={async () => {
72+
try {
73+
await GoogleSignin.hasPlayServices();
74+
const userInfo = await GoogleSignin.signIn();
75+
if (userInfo.idToken) {
76+
const { data, error } = await supabase.auth.signInWithIdToken({
77+
provider: "google",
78+
token: userInfo.idToken,
79+
});
80+
console.log(error, data);
81+
} else {
82+
throw new Error("no ID token present!");
83+
}
84+
} catch (error: any) {
85+
if (error.code === statusCodes.SIGN_IN_CANCELLED) {
86+
Alert.alert("Error", "cancelled");
87+
// user cancelled the login flow
88+
} else if (error.code === statusCodes.IN_PROGRESS) {
89+
// operation (e.g. sign in) is in progress already
90+
Alert.alert("Error", "in progress");
91+
} else if (error.code === statusCodes.PLAY_SERVICES_NOT_AVAILABLE) {
92+
// play services not available or outdated
93+
} else {
94+
// some other error happened
95+
Alert.alert("Error", "other");
96+
}
97+
}
98+
}}
99+
/>
100+
);
101+
}
56102
function SignedInView({ user }: { user: User }) {
57103
return (
58104
<View className="flex gap-4">
@@ -90,17 +136,6 @@ function SignedOutView() {
90136
}
91137
};
92138

93-
const signInWithGoogle = async () => {
94-
try {
95-
const { error } = await supabase.auth.signInWithOAuth({
96-
provider: "google",
97-
});
98-
if (error) return Alert.alert("Error", error.message);
99-
} catch (e) {
100-
console.error("Unexpected error from Google SignIn: ", e);
101-
}
102-
};
103-
104139
return (
105140
<View className="space-y-4">
106141
<Text className="mb-4 text-2xl font-bold text-zinc-200">Sign In</Text>
@@ -127,12 +162,7 @@ function SignedOutView() {
127162
or
128163
</Text>
129164
</View>
130-
<Text
131-
className="mb-2 mr-2 inline-flex w-full items-center justify-between rounded-lg bg-[#4285F4] px-5 py-2.5 text-center text-sm font-medium text-white hover:bg-[#4285F4]/90 focus:outline-none focus:ring-4 focus:ring-[#4285F4]/50 dark:focus:ring-[#4285F4]/55"
132-
onPress={signInWithGoogle}
133-
>
134-
<Text className="flex-1 text-center">Continue with Google</Text>
135-
</Text>
165+
<GoogleSignIn />
136166
</View>
137167
);
138168
}

pnpm-lock.yaml

+18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)