Description
openedon Dec 4, 2023
Version
SDK Platform: C#
SDK Version: Bot Builder 4.21.0
Active Channels: Teams
Deployment Environment: Azure Bot Service
Describe the bug
404 NOT FOUND when trying to GET the user token from teams with this request:
https://api.botframework.com/api/usertoken/GetToken?userId={user-id}&connectionName=BotOAuth&channelId=msteams
When using my own id I can get a token, but my colleagues cannot, when I send them a link to "test connection" from the Azure Bot page, they can get their token perfectly fine.
Expected behavior
It should return 200 with a token, just what happens with my user-id or return a prompt to allow access?
Additional
I am using the AdapterWithErrorHandler : CloudAdapter
with base.Use(new TeamsSSOTokenExchangeMiddleware(storage, configuration["ConnectionName"]));
and the main code can be found below. The tokenResponse is null due to the internal request getting a 404 NOT FOUND response.
protected override async Task OnMessageActivityAsync(ITurnContext<IMessageActivity> turnContext, CancellationToken cancellationToken)
{
var userTokenClient = turnContext.TurnState.Get<UserTokenClient>();
var tokenResponse = await userTokenClient.GetUserTokenAsync(turnContext.Activity.From.Id, _connectionName, turnContext.Activity.ChannelId, null, cancellationToken).ConfigureAwait(false);
if (tokenResponse == null)
{
// Tried this, but this should be needed when using sso?
var oauth = new OAuthCard(text: "test", connectionName: _connectionName, new List<CardAction>()
{
new CardAction(type: ActionTypes.Signin, title: "test")
});
await turnContext.SendActivityAsync(MessageFactory.Attachment(oauth.ToAttachment()));
return;
}
// Other code here that needs the tokenResponse
}