I am making react native app which will store data in google sheet. Storing data in sheet is available only with oauth token. Basic api token doesnt allow post requests.
For login i tried using two libraries but same error https://github.com/react-native-google-signin/google-signin
@react-native-google-signin/google-signin
react-native-google-signin
This is my code
import React, { useEffect } from 'react';
import {
GoogleSignin,
GoogleSigninButton,
statusCodes,
} from '@react-native-google-signin/google-signin';
const WEB_CLIENT_ID = '123crnslgq7d.apps.googleusercontent.com ';
GoogleSignin.configure({
scopes: ['https://www.googleapis.com/auth/drive.readonly'],
webClientId: WEB_CLIENT_ID,
});
const signIn = async () => {
try {
await GoogleSignin.hasPlayServices();
const userInfo = await GoogleSignin.signIn();
console.log(userInfo)
} catch (error) {
console.log(JSON.stringify(error))
}
};
function App(): JSX.Element {
useEffect(()=>{
signIn();
}, [])
return (
<>
Test
</>
)
}
My app shows oauth login panel, i choose the email and get this error.
{"nativeStackAndroid":[],
"userInfo":null,
"message":"A non-recoverable sign in failure occurred","code":"12500"}
I followed a bunch of tutorials to set up my project in google console, for example https://www.youtube.com/watch?v=EmtPTgE2_JY
Anyway:
- clientId is correct
- email i am using to login is listed as test user, and project owner
- google people api, and google sheet api is enabled in console
Any idea what I am missing? I spent two days trying to figure this out :/