Google.logInAsync Safari problem

#1

Hello all!
I’ve got a problem while trying to use the Expo.Google.logInAsync function.
When the function executes, the app opens Safari but, I get the Safari error: “Safari cannot open the page because it could not establish a secure connection to the server”.

I’m using the expo IOS simulator and this is my code:

  async loginWithGoogle() {
    this.setState({loading: 'google'})
    try {
      const result = await Expo.Google.logInAsync({
        androidClientId: credentials.androidClientId,
        iosClientId: credentials.iosClientId,
        scopes: ['profile', 'email']
      })

      if (result.type === 'success') {
        await loginWithGoogle({accessToken: result.accessToken}, this.props.client)
      }
    } catch (error) {
      const errorMessage = error.message.replace('GraphQL error: ', '')
      Alert.alert('Login error', errorMessage)
    }
    this.setState({loading: null})
  }
#2

hi @jjgumucio, if you are using the ios simulator, you may need to put in additional ids (ie) iosStandaloneAppClientId and webClientId.

See:


https://docs.expo.io/versions/latest/sdk/google.html

#3

Thanks @quinlanj! I’ll check it out and comment afterwards.

#4

I just added the iosStandaloneAppClientId and the webClientId and didn’t solve the problem.

I think my problem is different from the one you mention because I never get the google response. Safari opens up and shows the mentioned error (connection not secure) so I never get to authorize the app.

I’m really stuck here…

Any pointers would be very appreciated.

#5

Also, I have discovered that Safari, while opening the browser to authorize the app, is taking an old iOS client id. I don’t know why or where is it taking it from. My code is using the new one. I read docs and it says that the web interface uses your device stored data so, should I clean up my PCs Safari cache and stuff?

Regards

#6

Also, I have made a post request using the correct clientId using the python requests library and the request was successful and I got the authorization page as a result.

How do I make Expo to “forget” the old client Id? Do I have to rebuild the project?

#7

@jjgumucio if you’re using iosStandaloneAppClientId, you’ll have to re run exp build when you change that value.

#8

Yes, I’m uploading the new IPA to the App Store to test it.

closed #9

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.