twilio / twilio-voice-react-native-app

Other
37 stars 21 forks source link

Android / Getting GET_ACCESS_TOKEN_REJECTED #85

Closed spuri22 closed 9 months ago

spuri22 commented 1 year ago

I am trying to bring up the android app based on the instructions. Login succeeds, but I get GET_ACCESS_TOKEN_REJECTED. What could be the cause? Any configuration I am missing?

Logs on Android emulator console.

LOG registration/loginAndRegister/pending LOG user/login/pending LOG user/login/fulfilled LOG voice/getAccessToken/pending LOG voice/getAccessToken/rejected { "reason": "FETCH_ERROR", "error": { "name": "TypeError", "message": "Network request failed", "stack": "TypeError: Network request failed\n at anonymous (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.twiliovoicereactnativereferenceapp&modulesOnly=false&runModule=true:21299:33)\n at apply (native)\n at anonymous (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.twiliovoicereactnativereferenceapp&modulesOnly=false&runModule=true:26307:26)\n at _callTimer (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.twiliovoicereactnativereferenceapp&modulesOnly=false&runModule=true:26246:17)\n at callTimers (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.twiliovoicereactnativereferenceapp&modulesOnly=false&runModule=true:26402:19)\n at apply (native)\n at callFunction (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.twiliovoicereactnativereferenceapp&modulesOnly=false&runModule=true:2435:36)\n at anonymous (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.twiliovoicereactnativereferenceapp&modulesOnly=false&runModule=true:2197:31)\n at guard (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.twiliovoicereactnativereferenceapp&modulesOnly=false&runModule=true:2387:15)\n at callFunctionReturnFlushedQueue (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.twiliovoicereactnativereferenceapp&modulesOnly=false&runModule=true:2196:21)" } } LOG registration/loginAndRegister/rejected { "reason": "GET_ACCESS_TOKEN_REJECTED" } ERROR {"reason": "GET_ACCESS_TOKEN_REJECTED"}

mhuynh5757 commented 1 year ago

Hi @spuri22 thanks for reaching out. The Reference App is trying to communicate with your Reference Server at the URL defined in the app/.env file. This DEFAULT_URL env var is baked into the app upon compilation, so please make sure to set the value before building the application.

There are several ways to expose the server to the app. One way is using a tool like ngrok. Start the server, have ngrok point at it, and then set the .env DEFAULT_URL to the ngrok url.

Since you're on Android, you can also leave the DEFAULT_URL as localhost and do something like adb reverse tcp:3030 tcp:3030 to tunnel the emulator to your local machine. This way, when the app makes a request to it's "localhost:3030" it's actually reaching your physical device's localhost:3030.

mhuynh5757 commented 9 months ago

Closing this issue now, please reach out again if you need further assistance.