Error: ExpoAppAuth.Get Auth: Network error

Hello everyone,
Currently I’m building an application where I would like to make a request to an 3rd party oAuth Service (Not Google/Facebook), and I’m using Expo AppAuth to connect to their server. But when I did that, it always returns Error: ExpoAppAuth.Get Auth: Network error without further information. I tested it with my postman and it totally works fine. My internet connection has no issues at all too, and it happens in both Android & iOS. I will provide my codes to give better information

accessoAuth = async () => {
    const config = {
      issuer: 'https://isellershop.com/oauth/token',
      clientId: 'ID',
      clientSecret: 'SECRET',
      scopes: ['payment', 'oAuth'],
      additionalParameter:  JSON.stringify(paydata)
    }

    const authState = await AppAuth.authAsync(config)
      .then(response => response.json())
      .then((response) => console.log(response))
      .catch((error, state) => console.log(`Error: ${error}`));
  }

These are my dependencies:
“expo”: “^34.0.3”,
“expo-app-auth”: “~6.0.0”,
“react”: “16.8.3”,
“react-native”: “https://github.com/expo/react-native/archive/sdk-34.0.0.tar.gz”,

Thank you for your support fam!

Hello @notbrent @adamjnav ! Sorry to bother you but I need some help regarding this.

Thank you

This is related to the issue at Fix typo in AppAuthModule.createOAuthServiceConfiguration by craig-bishell · Pull Request #5311 · expo/expo · GitHub - there is an error in a ternary operator in expo-app-auth which will get rolled into an upcoming release. In the meantime, you must specify a dummy value for registrationEndpoint in your service configuration object.

1 Like

Sorry, I could not comprehend your explanation. Can you give me more details what to add in the code? Or what should I modify to get the access token?

Thank you :slight_smile:

I changed my config into:

 const config = {
      issuer: 'https://isellershop.com/oauth/token',
      clientId: CLIENT_ID,
      clientSecret: CLIENT_SECRET,
      scopes: ['payment', 'oAuth'],
      additionalParameter:  JSON.stringify(paydata),
      registrationEndpoint: 'abc'
    }

but it still returns Error: ExpoAppAuth.Get Auth: Network error

Here’s the fix:

-        config.containsKey(AppAuthConstants.Props.REGISTRATION_ENDPOINT) ? null : Uri.parse(config.get(AppAuthConstants.Props.REGISTRATION_ENDPOINT))
+        config.containsKey(AppAuthConstants.Props.REGISTRATION_ENDPOINT) ? Uri.parse(config.get(AppAuthConstants.Props.REGISTRATION_ENDPOINT)) : null

As you can see it’s trying to parse the “registrationEndoint” as a URI so maybe try something like ‘https://example.com/’ instead of ‘abc’.

Hello, thank you for your response. I overwrite the file in
node_modules/expo-app-auth/android/src/main/java/expo/modules/appauth/AppAuthModule.java and saved it. But nothing seems to be changed

 const config = {
      issuer: 'https://isellershop.com/oauth/token',
      clientId: CLIENT_ID,
      clientSecret: CLIENT_SECRET,
      scopes: ['payment', 'oAuth'],
      serviceConfiguration: {
        registrationEndpoint: 'https://example.com'
      }
    }

    const authState = await AppAuth.authAsync(config)
      .then(response => response.json())
      .then((response) => console.log(response))
      .catch((error, state) => console.log(`Error: ${error}`));
    
  }

Just to confirm, whether my code is right or not? Because I can’t seem to find the solution.

Thank you for your help!

Hi

Unfortunately, just replacing the AppAuthModule.java file will not do anything. I just pointed to the diff so you could see that the code was trying to parse the registrationEndoint value as a URI. Also, I’m just guessing at what might be the problem/workaround based on what @chitova263 said and the diff. I have not yet had a need for AppAuth.

Based on the documentation and the registrationEndpoint workaround, I think your code is correct. So I hope @chitova263 or someone else has some more suggestions for you.

Hi

Why it won’t do anything? I thought it’s possible to modify it locally, but when you reinstall the package, the changes will be gone. Correct me if I’m wrong

I tried to add the registration Endpoint Workaround by specifying a dummy values. Turns out there is an another error. I’m really tired of this

Need some help please! Thank you

That is generally true of JavaScript code in node_modules, but not Java code. That particular file is not used as-is. It has to be compiled into the Expo client app that is installed on the phone. So as far as I understand it there are two ways you could get the fix. 1.) Wait for a new version of the Expo app; 2.) Compile a version of the Expo app yourself and distribute that to your users.

About the current error, it looks to me like something is parsing your registrationEndpoint, but it doesn’t like it for some reason. Are you still using https://example.com or something else?

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