Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Its not redirecting to mobile app after Google login, instead it goes to google.com #5032

Closed
reactexcel opened this issue Jul 22, 2019 · 27 comments
Labels
needs more info To be used when awaiting reporter response

Comments

@reactexcel
Copy link

reactexcel commented Jul 22, 2019

Sorry @cruzach to open this issue again, i need to open this issue again as:
still its not working
here is my code :-

try {
const result = await Google.logInAsync({
androidClientId:"xxxx",
scopes: ['profile', 'email'],
redirectUrl:${AppAuth.OAuthRedirect}:/oauth2redirect/google
});
console.log(result);
} catch(e) {
console.log({e});
}
i did not make any change in node_modules.
and one more question , what should be the package name in production mode?
As now i am using host.exp.exponent for dev mode and com.xxxx(as it is in app.json) so is it right?
Thanks

@martin9908
Copy link

Google.loginAsync is already deprecated please use GoogleSignIn for google authentication, just follow this link on how to update your code: https://docs.expo.io/versions/v33.0.0/sdk/google-sign-in/

@reactexcel
Copy link
Author

no @martin9908 its not deprecated its working fine, just not redirecting to app after google login
also i was trying google login with https://docs.expo.io/versions/v33.0.0/sdk/google-sign-in/
but getting error after first login that's it Error : there is some asyn operation still in progress
and then its failed again and again.
Please help me out i have spend a week got the google login
but bad luck!
Thanks.

@cruzach
Copy link
Contributor

cruzach commented Jul 22, 2019

You need to pass the redirectUrl as a string, easiest would be to use JavaScript template strings

@reactexcel
Copy link
Author

reactexcel commented Jul 22, 2019

i have already done this but still going to google.com after login
@cruzach please help me i am so worry about this.
see here is my code

try {
const result = await Google.logInAsync({
androidClientId:"xxxx",
scopes: ['profile', 'email'],
redirectUrl:${AppAuth.OAuthRedirect}:/oauth2redirect/google
});
console.log(result);
} catch(e) {
console.log({e});
}

@reactexcel
Copy link
Author

reactexcel commented Jul 22, 2019

@cruzach
i am already using the template string as you made the changes in the pr

check my App.json once , i am using sdk32

{
"expo": {
"name": "xxxx",
"slug": "eventapp",
"privacy": "public",
"sdkVersion": "32.0.0",
"platforms": [
"ios",
"android"
],
"facebookAppId": "xxxxx",
"facebookDisplayName": "xxxxx",
"facebookScheme": "xxxxx",
"icon":"./assets/images/icon_events-channel.png",
"version": "1.0.0",
"orientation": "portrait",
"splash": {
"image": "./assets/images/splash1.png",
"resizeMode": "cover"
},
"notification": {
"icon": "./assets/images/ic_stat_call_whitee.png",
"color":"#FF6CC9"
},
"android": {
"package":"com.xxxx",
"googleServicesFile":"./assets/google-services.json",
"permissions" : [
"ACCESS_FINE_LOCATION",
"READ_EXTERNAL_STORAGE",
"MANAGE_DOCUMENTS",
"WRITE_EXTERNAL_STORAGE",
"CAMERA",
"CALENDAR",
"READ_CALENDAR",
"WRITE_CALENDAR"
]
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": [
"**/*"
],
"ios": {
"bundleIdentifier":"xxx",
"supportsTablet": true,
"config":{
"googleSignIn":{
"reservedClientId":"xxx"
}
},
"infoPlist": {
"NSCameraUsageDescription": "xxx needs your permissiom to access camera for uploading user profile."
}
}
}
}

and Package.json

{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"eject": "expo eject",
"test": "node ./node_modules/jest/bin/jest.js --watchAll"
},
"jest": {
"preset": "jest-expo"
},
"dependencies": {
"@expo/samples": "2.1.1",
"axios": "^0.18.0",
"expo": "^32.0.0",
"expo-app-auth": "^5.0.1",
"expo-facebook": "^4.0.0",
"expo-google-app-auth": "^6.0.0-rc.0",
"immutability-helper": "^3.0.0",
"lodash": "^4.17.11",
"moment": "^2.24.0",
"react": "16.5.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz",
"react-native-autocomplete-input": "^3.6.0",
"react-native-get-location": "^1.1.2",
"react-native-image-picker": "^0.28.1",
"react-native-modalbox": "^1.7.1",
"react-native-snap-carousel": "^3.7.5",
"react-native-timer": "^1.3.6",
"react-native-touch": "0.0.2",
"react-native-unimodules": "^0.4.2",
"react-navigation": "^3.0.9",
"react-redux": "^6.0.0",
"redux": "^4.0.1",
"redux-actions": "^2.6.4",
"redux-logger": "^3.0.6",
"redux-saga": "^1.0.1"
},
"devDependencies": {
"babel-preset-expo": "^5.0.0",
"jest-expo": "^32.0.0"
},
"private": true
}

@cruzach
Copy link
Contributor

cruzach commented Jul 22, 2019

@reactexcel - please don't open new issues, it doesn't increase the response time. You still haven't followed the issue template which we provide for you. Please go back and edit your post to include all of the information we ask for, formatted correctly. In the meantime, I see you're using SDK 32. Could you test your code on an SDK 33 project, and let me know if you hit the same error?

Also- it's really helpful to place "```" before and after your code that you are sharing, as that formats it very nicely.

@reactexcel
Copy link
Author

ok won't create the same issue
and thanks for the reply @cruzach

as you told me to check it with sdk33, i check it on dev mode but getting no response (no error no response).
its really more bad than with sdk32

@reactexcel
Copy link
Author

and @cruzach please can you tell me why is GoogleSignIn giving an error of some async operation are still in pending.

@cruzach
Copy link
Contributor

cruzach commented Jul 23, 2019

as you told me to check it with sdk33, i check it on dev mode but getting no response (no error no response).

You've most likely misconfigured something in the setup here. I would go through the docs and make sure you've followed each step.

please can you tell me why is GoogleSignIn giving an error of some async operation are still in pending.

Without a way to reproduce it on my end, I can't say why this would/is happening.

@cberigan
Copy link

cberigan commented Aug 26, 2019

I too am seeing this issue. It's only happening in android standalone apps. Upon closer inspection, the expo-app-auth module generates a default redirect url as ${ExpoAppAuth.OAuthRedirect}:/oauthredirect while the expo-google-app-auth module generates a default redirect url as ${reverseClientId}:/oauth2redirect/google. Looks like a bug to me.

I've provided a solution on my end by using ${AppAuth.OAuthRedirect}:/oauthredirect as the redirectUrl.

@cruzach
Copy link
Contributor

cruzach commented Aug 26, 2019

@cberigan can you provide a way for me to reproduce this?

@cberigan
Copy link

@cruzach Let me put something together. It may take me a day or 2.

@cberigan
Copy link

cberigan commented Aug 26, 2019

google-auth-test.zip

@cruzach Attached is a sample project. Just build the expo project for android, install, and run. The App.js contains some comments to reproduce.

@cruzach
Copy link
Contributor

cruzach commented Aug 27, 2019

@cberigan - the standalone build failed 😕

@cberigan
Copy link

What was the issue? I was able to build it on android.

@cruzach
Copy link
Contributor

cruzach commented Aug 28, 2019

Fixed the build issue, it was on my end

The issue you're seeing is the same as 4655, which was fixed in this PR (it just hasn't been published yet)

Manually made the PR change to the node_modules/expo-google-app-auth package, published, and the app works as intended

@cruzach cruzach closed this as completed Aug 28, 2019
@santhoshvkumar
Copy link

Is there is any round around approach for solving this issue? I just updated the application to 34.0.0. It's redirecting to the google.com, If there is any temporary fix that would be helpful.

@cruzach
Copy link
Contributor

cruzach commented Sep 6, 2019

You can pass ${AppAuth.OAuthRedirect}:/oauth2redirect/google in as your redirectUrl for a temporary workaround (for standalone apps)

@vinagrito
Copy link

vinagrito commented Sep 10, 2019

@cruzach The fix you made on the merged PR makes sense and after changing my code I can see that the config passed into the logInAsync function is the expected one - com.example.my-example:/oauth2redirect/google.
And yet my app keeps redirecting to google.com. Same as @santhoshvkumar I'm on the latest versions of the SDK and the expo-google-app-auth library

@cberigan
Copy link

@vinagrito Read my comment. Use ${AppAuth.OAuthRedirect}:/oauthredirect as the redirectUri. If in doubt, download the project zip in one of my comments and it has both the reproduced bug and solution

@vinagrito
Copy link

vinagrito commented Sep 10, 2019

@cberigan indeed the test app you posted works as expected 😄. Should I believe then my oauth clients are not configured correctly?. Should my API key be restricted to android apps?. Also, I see that the app.json reads:

...
"android": {
     "package": "com.testapp.expogoogleauthbug"
  }

I don't see a config.googleSignIn attribute there... According to https://docs.expo.io/versions/latest/sdk/google/#deploying-to-a-standalone-app-on-android I need to those defined.

@vinagrito
Copy link

@cberigan Is there a correlation between the SHA1 hash in expo used for the signing with the one defined in the google developer oauth client ID?

@vinagrito
Copy link

@cberigan OK, so I managed to fix it. My identifier contains a capital letter, kind of a:
com.myCoolidentifier.identifier so I was pasting the same value in the oauth client ID. well, seems like that's not valid. So I just lowered case everything and that's it for now

@andersco
Copy link

@cberigan OK, so I managed to fix it. My identifier contains a capital letter, kind of a:
com.myCoolidentifier.identifier so I was pasting the same value in the oauth client ID. well, seems like that's not valid. So I just lowered case everything and that's it for now

@vinagrito that was my issue too...thanks for posting this!

@kgpasta
Copy link

kgpasta commented Oct 22, 2019

@vinagrito @andersco which oauth client ID did you end up changing? I'm having the same issue, and we also have a capital letter in our identifier, but changing it in the Google Developer Console seems to have no effect

@andersco
Copy link

@kgpasta I changed the package name in my oauth client ID that is used for Android (not expo) to be all lowercase and that fixed the issue for me.

@kgpasta
Copy link

kgpasta commented Nov 1, 2019

thanks @andersco that fixed it!

@lock lock bot added the outdated label May 5, 2020
@lock lock bot locked and limited conversation to collaborators May 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs more info To be used when awaiting reporter response
Projects
None yet
Development

No branches or pull requests

8 participants