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

reason": "TOKEN_RESPONSE_NOT_OK #124

Open
ashsharma1 opened this issue Oct 16, 2023 · 9 comments
Open

reason": "TOKEN_RESPONSE_NOT_OK #124

ashsharma1 opened this issue Oct 16, 2023 · 9 comments

Comments

@ashsharma1
Copy link

ashsharma1 commented Oct 16, 2023

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
Copy link
Author

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
Copy link
Contributor

kpchoy commented Oct 19, 2023

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
Copy link
Contributor

kpchoy commented Oct 19, 2023

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

@ashsharma1
Copy link
Author

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
Copy link
Contributor

kpchoy commented Oct 20, 2023

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
Copy link
Author

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
Copy link
Contributor

kpchoy commented Oct 23, 2023

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
Copy link
Author

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
Copy link
Contributor

Hello @ashsharma1 are you still encountering this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants