sysgears / apollo-universal-starter-kit

Apollo Universal Starter Kit is a SEO-friendly, fully-configured, modular starter application that helps developers to streamline web, server, and mobile development with cutting-edge technologies and ultimate code reuse.
https://apollokit.org
MIT License
1.68k stars 323 forks source link

Add native Expo Google API integration for social login #1007

Open larixer opened 5 years ago

larixer commented 5 years ago

Add native Expo Google API integration for login as a module next to WebBrowser implementation, e.g. auth/expo-google next to auth/google Relevant docs: https://docs.expo.io/versions/v31.0.0/sdk/google

DhirajMohata commented 1 year ago

i want to work on this issue

DhirajMohata commented 1 year ago

i dont have any experince its my first contribution

yadavvishal commented 1 year ago

Set Up Google Developer Console:

Go to the Google Developer Console. Create a new project or use an existing one. Enable the "Google Sign-In" API for your project. Configure the OAuth consent screen and add necessary information like application name, support email, etc. Create OAuth 2.0 credentials and set the authorized JavaScript origins and redirect URIs. For Expo apps, the redirect URI will be something like https://auth.expo.io/@your-username/your-app-slug

import Constants from 'expo-constants';

const GOOGLE_ANDROID_CLIENT_ID = 'YOUR_ANDROID_CLIENT_ID'; const GOOGLE_IOS_CLIENT_ID = 'YOUR_IOS_CLIENT_ID';

Constants.manifest.extra = { androidClientId: GOOGLE_ANDROID_CLIENT_ID, iosClientId: GOOGLE_IOS_CLIENT_ID, };

import * as GoogleSignIn from 'expo-google-sign-in';

// ...

const handleGoogleSignIn = async () => { try { await GoogleSignIn.initAsync({ clientId: Constants.manifest.extra.androidClientId, }); await GoogleSignIn.askForPlayServicesAsync(); const { type, user } = await GoogleSignIn.signInAsync(); if (type === 'success') { // User signed in successfully, handle the user object console.log(user); } else { // User cancelled the login request console.log('Google Sign-In cancelled.'); } } catch (error) { // Handle error console.error(error); } };

// ...