Skip to content

404 Not found when trying to use Teams SSO to get the user token #6625

Open

Description

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
}

Azure config:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Area: TeamsThe issue is related to Teams supportbugIndicates an unexpected problem or an unintended behavior.needs-triageThe issue has just been created and it has not been reviewed by the team.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions