可以通过Azure go sdk接收用户信息吗?

发布于 2025-01-09 10:32:07 字数 172 浏览 0 评论 0原文

我需要使用 Azure 服务,因此我使用 github.com/Azure/azure-sdk-for-go,但也想获取用户电子邮件。为此,我必须使用图形 SDK (github.com/microsoftgraph/msgraph-sdk-go) 吗?

我的应用程序允许对多租户 AD 用户和个人帐户进行身份验证。

I need to work with Azure services, so I use github.com/Azure/azure-sdk-for-go but also want to get a user email. Do I have to use the graph SDK (github.com/microsoftgraph/msgraph-sdk-go) for this?

My app allows authentication of both multi-tenant AD users and personal accounts.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

时光与爱终年不遇 2025-01-16 10:32:07

我必须使用图形 SDK吗
(github.com/microsoftgraph/msgraph-sdk-go)为此?

是的,您需要使用 msgraph-sdk-go SDK 与 Graph API 进行交互。您可以在此处找到有关使用 SDK 的更多信息:https://learn .microsoft.com/en-gb/graph/sdks/sdks-overview

Do I have to use the graph SDK
(github.com/microsoftgraph/msgraph-sdk-go) for this?

Yes, you would need to use msgraph-sdk-go SDK to interact with Graph API. You can find more information about using the SDK here: https://learn.microsoft.com/en-gb/graph/sdks/sdks-overview.

唱一曲作罢 2025-01-16 10:32:07

就我而言,我使用 oauth2 令牌来验证 azure 和 graph SDK。不可能使用相同的令牌来使用这两个 SDK,因为同时指定了图形 https://graph.microsoft.com/.default 和 azure 服务管理 https://management.azure 的范围.com//.default 返回有关范围无效的错误。

因此,您不能将Azure SDK用于个人帐户,它必须是工作帐户。 Microsoft 允许使用同一电子邮件(和不同的密码)拥有个人帐户和工作帐户。 Azure SDK 确实有 graphrbac 服务,理论上可以用来获取用户电子邮件,但该服务最近已被宣布已弃用。

我最终意识到我并不真正需要用户电子邮件,拥有订阅 ID 就可以了。

In my case I used an oauth2 token to authenticate both azure and graph SDKs. It's impossible to work with both SDKs using the same token because specifying scopes for both graph https://graph.microsoft.com/.default and azure services management https://management.azure.com//.default returns error about the scope being invalid.

So, you can't use Azure SDK for personal accounts, it must be a work account. Microsoft allows to have both personal and work account using the same email (and different passwords). Azure SDK does have graphrbac service that in theory can be used to fetch a user email but this service has been recently announced as deprecated.

I've ended up realizing I don't really need a user email, I'm fine with having a subscription ID.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文