1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] OAuth Card [No dialogs] does not work in MS Teams client. Works in Emulator and...

Discussão em 'Python' iniciado por Stack, Outubro 7, 2024.

  1. Stack

    Stack Membro Participativo

    What i am trying to do?


    I am trying to display a OAuth Card to the user to sign in, and fetch the access JWT token so that i can use it to impersonate him/her in my Teams Bot. The App configurations and the Bot have been configured as per the following link exactly.

    https://learn.microsoft.com/en-us/m.../add-authentication?tabs=python,python-sample

    Current State


    I am not using the Dialogs feature of the SDK, rather, i send the OAuth card directly like the following.

    async def dispatch_signin_card(self, turn_context):
    oauth_card = OAuthCard(
    text="Sign in to continue",
    connection_name=self.connection_name,
    buttons=[
    CardAction(
    type=ActionTypes.signin,
    title="Sign in"
    )
    ]
    )

    await turn_context.send_activity(
    Activity(attachments=[CardFactory.oauth_card(oauth_card)]))


    Everytime there is a message (on_message_activity) i check if the turn_context object has a token to make a decision of sending a new signin card. like the following

    async def get_token(self, turn_context: TurnContext):
    # Try to get the token from the token exchange or from a prior sign-in
    token_response = None

    # Check if the activity contains a token response
    if turn_context.activity.value and "token" in turn_context.activity.value:
    token_response = TokenResponse(token=turn_context.activity.value["token"])

    if not token_response:
    # If no token in the activity, try to retrieve it from the OAuth connection
    token_response = await turn_context.adapter.get_user_token(turn_context, self.connection_name)

    return token_response


    The Card functions perfectly in the Emulator as shown below and in the web chat from the Azure Bot Interface.

    [​IMG]

    It does not work in Teams, neither in the Desktop Client or the Web Client. It gives me the following error.

    [​IMG]

    What have i tried already

    • I have tried adding *.botframwework.com, token.botframework.com, my ngrok instance url, and graph.microsoft.com to the valid Domains list, as i read them on various support articles.
    • I have tried triple checking my App Registrations, and their configurations if they have been configured correctly.
    • I have tried mannually generating the signin link, but cannot decipher how to the OAuth link is generated. I have noticed that everytime a new link is generated, it takes the form https://token.botframework.com/api/oauth/signin?signin=some_ids
    • I have also read many posts which talk about waiting for a bit (4 Hours), before the changes to an App Manifest are actually reflected on Teams. (Not the problem unfortunately).
    • I tried inspecting traffic on my ngrok instance, when i click the signin button from teams. There is no activity whatsoever.

    I am good with honestly any more directions for my investigation. I ran out of ideas and thought of posting a question here (in hopes of not having it marked as duplicate), to help me solve this error.

    BTW, i use the package botbuilder-integration-aiohttp==4.15.0.

    Continue reading...

Compartilhe esta Página