首页 > 解决方案 > 如何使用 Microsoft Share To Teams 按钮对用户进行身份验证?

问题描述

如this microsoft offcial doc中所述,我在我的html页面上添加了共享到团队按钮,但是在打开的弹出窗口中它给出了错误

https://docs.microsoft.com/en-us/microsoftteams/platform/concepts/build-and-test/share-to-teams#:~:text=pop%2Dup%20experience%3A-,Embed%20a% 20Share%20to%20Teams%20button,js%20script%20on%20your%20webpage.&text=添加%20a%20HTML%20element%20on,in%20the%20data%2Dhref%20attribute.&text=或者%2C%20if%20you% 20want%20a,icon%2Dpx%2Dsize%20attribute

在此处输入图像描述.

那么如何对用户进行身份验证,我们是否必须为此调用另一个 API 或其他任何东西......

当我搜索时,我发现了 Graph API,但不知道这是我需要的或如何使用它。

我创建了这个简单的 html 页面。

在此处输入图像描述

HTML 代码

<html>
<head>
    <title>Hello Teams</title>
    <script async defer src="https://teams.microsoft.com/share/launcher.js"></script>
    </head>
    <body>
        <h1>Share to Teams</h1>
        <p>Please click on this icon below</p>
        <span
        class="teams-share-button"
        data-icon-px-size="64"
        data-href="https://docs.microsoft.com/en-us/graph/teams-concept-overview"
         data-preview="false"
        data-msg-text="Hello Avengers"
        data-assign-title="Demo Share"
        data-assign-instr="Demo Default Assignment Instructions"></span>
    
    </body>
    </html>

标签: javascriptmicrosoft-teamsmicrosoft-graph-teamsmicrosoft-identity-platformmicrosoft-identity-web

解决方案


当我在隐身窗口中打开共享到团队按钮 html 文件时,我能够重现您的问题。

我已经针对这个问题提出了一个错误,相关团队正在努力解决这个问题。

或者,您可以使用下面的代码,请仔细阅读

<div class="teams-share-button" data-href="https://docs.microsoft.com">
<a target="ms-teams-share-popup" onclick="window.open('https://teams.microsoft.com/share?href=https%3A%2F%2Fdocs.microsoft.com&amp;referrer=docs.microsoft.com', 'ms-teams-share-popup', 'width=700,height=600'); return false" href="https://teams.microsoft.com/share?href=https%3A%2F%2Fdocs.microsoft.com&amp;referrer=docs.microsoft.com">
<img alt="Share to Microsoft Teams" src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0i...Zz4=" width="32" height="32">
</a>
</div>

推荐阅读