twilio / twilio-voice-react-native-app

Other
32 stars 15 forks source link

reason": "TOKEN_RESPONSE_NOT_OK #124

Open ashsharma1 opened 11 months ago

ashsharma1 commented 11 months ago

I set up the app and the server. While authenticated via username+pwd with auth0, I got the following response in the Log:

voice/getAccessToken/rejected {
  "reason": "TOKEN_RESPONSE_NOT_OK",
  "statusCode": 401,
  "error": {
    "name": "Error",
    "message": "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">
<title>Error</title>
</head>
<body>
<pre>InvalidTokenError: no applicable key found in the JSON Web Key Set
<br> &nbsp; &nbsp;at /Users/ash/nativereactdev/twilio-voice-react-native-app/server/node_modules/express-oauth2-jwt-bearer/dist/index.js:271:19
<br> &nbsp; &nbsp;at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
<br> &nbsp; &nbsp;at async /Users/ash/nativereactdev/twilio-voice-react-native-app/server/node_modules/express-oauth2-jwt-bearer/dist/index.js:374:24
</pre>
</body>
</html>
  }
}

I didn't see setting up any JWKS in the instructions. Is there anything I am missing here?

ashsharma1 commented 11 months ago

Looks like there were some items missing in the .env file. After adding those, I get a fresh new error:

voice/getAccessToken/rejected {
  "reason": "TOKEN_RESPONSE_NOT_OK",
  "statusCode": 404,
  "error": {
    "name": "Error",
    "message": "User info not found."
  }
}

Am I supposed to create a user in Twilio?

The Auth0 logs show a successful login.

kpchoy commented 11 months ago

Hi @ashsharma1 , did you fill out the .env for the server? https://github.com/twilio/twilio-voice-react-native-app/blob/main/server/example.env

It seems like you have correctly configured Auth0, but the app is failing at the Twilio Access Token step. The server and app need to be ran in conjunction.

kpchoy commented 11 months ago

We have an additional README in the server for setup: https://github.com/twilio/twilio-voice-react-native-app/tree/main/server#readme

ashsharma1 commented 11 months ago

Hi @kpchoy Thanks for the prompt response. I have fixed the issues with the .env files and now I am past the stage of getting the user info.

Now I get a fresh set of errors in the log.

registration/register/rejected {
  "reason": "NATIVE_MODULE_REJECTED",
  "error": {
    "name": "Error",
    "message": "Registration Error: 51007, Token authentication is rejected by authentication service",
    "code": "EUNSPECIFIED"
  }
}
 LOG  loginAndRegister/rejected {
  "reason": "REGISTER_REJECTED"
}
 ERROR  {"reason": "REGISTER_REJECTED"}
kpchoy commented 11 months ago

It looks like some of your Twilio env variables are incorrect. Can you double check and make sure those values match the values in Twilio Console.

ashsharma1 commented 11 months ago

After creating a brand new twilio account, I still get errors:

 LOG  accessToken =  {"status":"fulfilled","value":"eyJhbGciOiJIUzI1NiIsInR5....BY"}
 LOG  voiceRegisterResult =  {"status":"rejected","reason":{"nativeStackAndroid":[],"userInfo":null,"message":"Registration Error: 31400, Bad Request","code":"EUNSPECIFIED"}}
 LOG  registration/register/rejected {
  "reason": "NATIVE_MODULE_REJECTED",
  "error": {
    "name": "Error",
    "message": "Registration Error: 31400, Bad Request",
    "code": "EUNSPECIFIED"
  }
}
 LOG  loginAndRegister/rejected {
  "reason": "REGISTER_REJECTED"
}
 ERROR  {"reason": "REGISTER_REJECTED"}

Looks like when the app tries to register for voice, it receives an error. I have checked the token on JWT.io and it looks fine.

Can you please update the documentation on what all specific things should we do on a twilio side account to make this work.

Thanks.

kpchoy commented 11 months ago

The example.env has all the variables that you need.

Here is a link to authToken and accountSid: https://support.twilio.com/hc/en-us/articles/223136027-Auth-Tokens-and-How-to-Change-Them

Here is another to apiKey and apiKeySecret https://support.twilio.com/hc/en-us/articles/9318455807771-API-Keys-and-How-to-Change-Them

Do you have any errors in your server?

ashsharma1 commented 11 months ago

I am running the server in the repo under /server. I have not changed its code in any way. And its doing the auth with auth0 fine.

mhuynh5757 commented 7 months ago

Hello @ashsharma1 are you still encountering this issue?