botbuilder-js: Oauth prompt fails to start
After following the guide on using the OAuthPrompt
dialog from botbuilder-dialogs
and it seems like all requests related to retrieving the user token for a connection are failing with a status code of 401
, thus the prompt never makes it past the stage of trying to check if we have a token before starting the dialog prompt for the oauth connection.
I have properly configured appId
and appPassword
and am able to successfully use other api methods like getActivityMembers
from the BotFrameworkAdapter
adapter instance. However I noticed that when the SDK tries to make the request to check if we have a token for a user/connection it does not send any authorization header, thus it makes sense that the request fails with a 401
status code.
Here is the full error message + stack trace:
{ Error
at new RestError (/Users/agonbina/Gameon/bot/node_modules/ms-rest-js/lib/restError.ts:13:5)
at OAuthApiClient.<anonymous> (/Users/agonbina/Gameon/bot/node_modules/botframework-connector/src/oAuthApiClient.ts:83:21)
at Generator.next (<anonymous>)
at fulfilled (/Users/agonbina/Gameon/bot/node_modules/botframework-connector/lib/oAuthApiClient.js:11:58)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:118:7)
code: undefined,
statusCode: 401,
request:
{ headers:
{ 'Content-Type': 'application/json; charset=utf-8',
'User-Agent': 'Node/v9.10.1 (x64-Darwin-16.7.0) ms-rest-js/0.1.0 botframework-connector/4.0.0 Microsoft-BotFramework/3.1 (BotBuilder JS/4.0.0-preview1.2) Azure-SDK-For-Node',
cookie: '' },
rawResponse: false,
url: 'https://api.botframework.com/api/usertoken/GetToken?userId=default-user&connectionName=Facebook',
method: 'GET' },
response:
{ body:
PassThrough {
_readableState: [ReadableState],
readable: false,
domain: null,
_events: [Object],
_eventsCount: 4,
_maxListeners: undefined,
_writableState: [WritableState],
writable: false,
allowHalfOpen: true,
_transformState: [Object] },
headers: Headers { _headers: [Object] },
status: 401 },
body: undefined }
Happy to provide more information if necessary, otherwise this should be simple to re-produce by following the example provided in the docs for OAuthPrompt.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 1
- Comments: 17 (5 by maintainers)
the Method getUserTokenWithHttpOperationResponse(userId, connectionName, magicCode, options) has undefined options which set the header. In my case just calling GET on https://api.botframework.com/api/usertoken/GetToken?userId=default-user&connectionName=CmbAuth$
The samples work fine if you use symbolic links to what’s actually in the SDK instead of that preview version. I believe Steve is going to do a pass through all of the botbuilder packages in the packages.json, but for now, just create symbolic links to what is in the SDK or use the latest SDK releases.
@tschnoelzer same here, I tried pulling the repo and installing the npm packages from the pulled local folder but the issue does not seem to be fixed. It seems like the release process for this project is kinda messy right now. I am also not sure why the built source(javascript files) are versioned given that most of the codebase seems to be written in Typescript 😃