Search code examples
node.jsazurebotframeworkazure-language-understanding

I have a problem with starting my bot from emulator - BotFrameworkAdapter.processActivity(): 401 ERROR - NotBeforeError: jwt not active


I am developing a bot with Microsoft Bot Framework for Node.js.

I changed the LUIS App in the .bot file with a new one, and then I generated a new botFileSecret, I tested my bot locally with the Bot Framework Emulator and everything worked fine.

Then, I got this error:

Error finding key for token.
Available keys: -----BEGIN RSA PUBLIC KEY-----
jwtTokenExtractor.ts:132
MIIBCgKCAQEAt3J1hnS4aRZaZGq5JUw1iKsHynCUV9lMBe2MDArXGeQlN+w8Xw9v
U6InqmPVvJsUVyUkKE0jzn4dYLcwbTuttQ0hmN+lzNfGol04KKMIVdtTs1P0wo/+
VyJ88EuWM3lvDxyTw1PLim14UJ1856zdp2/kZLOSy+B46K96ENJ8b2yCP/VHRTd3
...
-----END RSA PUBLIC KEY-----
JwtTokenExtractor.getIdentity:err!
jwtTokenExtractor.ts:69
NotBeforeError {name: "NotBeforeError", message: "jwt not active", date: Tue Apr 02 2019 09:58:08 GMT+0200 (Romance Dayligh…, stack: "NotBeforeError: jwt not active
    at Object.modul…"}
jwtTokenExtractor.ts:69
BotFrameworkAdapter.processActivity(): 401 ERROR - NotBeforeError: jwt not active
botFrameworkAdapter.ts:555
(node:1888) UnhandledPromiseRejectionWarning: Error: NotBeforeError: jwt not active
warning.js:18
    at BotFrameworkAdapter.processActivity (c:\Users\SP-Montassar\Desktop\quicktext\zoe2\node_modules\botbuilder\src\botFrameworkAdapter.ts:556:19)
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:229:7)
(node:1888) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
warning.js:18
(node:1888) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

After researching, I found this article on Bot Framework Docs explaining how to resolve the bot authentication.

I followed up the steps ..

First I verified the App ID and the App Password from the Azure Portal, and then I deleted the APP ID and the App Password. I have verified that the bot starts fine. I sent a this HTTP request via commandLine to check authentication:

curl -X POST \
  https://login.microsoftonline.com/botframework.com/oauth2/v2.0/token \
  -H 'Content-Type: application/x-www-form-urlencoded' \
-d 'grant_type=client_credentials&client_id=<APP_ID>&client_secret=<APP_PWD>&scope=https://api.botframework.com/.default'

I've got a response with a valid access token :

{
    "token_type": "Bearer",
    "expires_in": 3600,
    "ext_expires_in": 3600,
    "access_token": "eyJ0eXAiOiJKV1QiLCJhbGGAKI..."
}

Then, I was blocked in the third step of the tutorial because I still have the some error above.

Any help for this issue please?


Solution

  • This issue is resolved by just creating a new botFileSecret for the .bot file.