英文:
Authenticating with Netatmo API using MSAL.NET results in "Error: ClientId is not a GUID."
问题
以下是翻译好的部分:
我正在编写一个Windows应用程序,用于从Netatmo获取气象站数据。
该应用程序需要使用Netatmo API进行身份验证(身份验证代码授予模式),我正在尝试使用MSAL的PublicClientApplicationBuilder
来实现这一点。
Netatmo应用程序注册提供的客户端ID是一个包含24个字符的字符串,而MSAL似乎只接受可解析为GUID的字符串。因此,该构建器引发了MsalClientException异常,其消息为:"错误:ClientId不是GUID"。
根据OAuth2(RFC 6749)的规定,客户端ID不必是GUID。
因此,问题是,是否有办法解决MSAL中这个奇怪的要求,还是应该使用不同的身份验证客户端?该应用程序已经使用MSAL来与outlook.office.com进行身份验证,因此这是我的首选。
英文:
I am writing a Windows app that will retrieve weather station readings from Netatmo.
The app needs to authenticate with Netatmo API (authentication code grant), and I am trying to use MSAL's PublicClientApplicationBuilder
for this.
The client Id provided by Netatmo's app registration is a 24 character string, while MSAL seams to accept only string that can be parsed into a GUID. Therefore, the builder throws a MsalClientException with message: "Error: ClientId is not a GUID.".
var publicClientApp = PublicClientApplicationBuilder
.Create("8543a5684dbe6325b15bcc4b")
.WithAuthority("https://api.netatmo.com/oauth2")
.Build();
According to OAuth2 (RFC 6749) the client Id is not required to be a GUID.
So the question is, is their a work-around for this odd requirement in MSAL, or should I use a different authentication client?
The app already uses MSAL to authenticate with outlook.office.com, therefore that was my first choice.
答案1
得分: 0
Microsoft身份平台(也称为Azure AD)专门使用GUID作为其客户端ID。由于MSAL是专为与此交互而设计的库,并且官方不支持其他身份提供程序,因此他们决定在库本身中强制执行此限制。这是他们GitHub存储库上的一个长期问题。在此期间,您可能需要使用不同的库,或自行开发。
英文:
The Microsoft identity platform (aka Azure AD) exclusively uses GUIDs for its client IDs. Since MSAL is a library designed specifically for interacting with this, and officially does not support other identity providers, they've decided to enforce this restriction in the library itself. Here's a longstanding issue on their GitHub repo.
In the meantime, you would probably have to use a different library, or roll your own.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论