英文:
OneDrive Uploader not working for education or workplace accounts
问题
所以我做了一个 OneDrive 上传工具,它使用 Azure,目前它不支持教育或工作场所账户。它只支持普通的 Microsoft 账户。如何使我的应用程序与其他类型的 Microsoft 账户兼容?
如果以下代码有帮助的话,我有以下代码(这是我尝试过的):
var accounts = await app.GetAccountsAsync();
firstAccount = accounts.FirstOrDefault();
authResult = await app.AcquireTokenInteractive(scopes)
.WithAccount(firstAccount)
.WithParentActivityOrWindow(new WindowInteropHelper(this).Handle)
.WithPrompt(Microsoft.Identity.Client.Prompt.SelectAccount)
.ExecuteAsync();
IPublicClientApplication publicClientApp = PublicClientApplicationBuilder.Create(client_id)
.WithRedirectUri("https://login.microsoftonline.com/common/oauth2/nativeclient")
.WithAuthority(AzureCloudInstance.AzurePublic, tenant)
.Build();
这些是我认为需要更改的主要代码区域,以便它可以工作(如果可能的话)。
它应该允许您登录到一个帐户并访问您的 OneDrive,但如果您尝试使用教育帐户登录,例如,它会出现以下错误消息:
英文:
So I have made a OneDrive uploader, which uses Azure, and currently it doesn't work with education or workplace accounts. It only works with normal Microsoft accounts. How can I make my app work with other kinds of microsoft accounts?
I have the following code if that helps: (this is what i have tried to do.)
var accounts = await app.GetAccountsAsync(); firstAccount = accounts.FirstOrDefault();
authResult = await app.AcquireTokenInteractive(scopes)
.WithAccount(firstAccount)
.WithParentActivityOrWindow(new WindowInteropHelper(this).Handle)
.WithPrompt(Microsoft.Identity.Client.Prompt.SelectAccount)
.ExecuteAsync();
IPublicClientApplication publicClientApp = PublicClientApplicationBuilder.Create(client_id)
.WithRedirectUri("https://login.microsoftonline.com/common/oauth2/nativeclient")
.WithAuthority(AzureCloudInstance.AzurePublic, tenant)
.Build();
these are the main areas of code which I think have to be changed in order for it to work. (if it is even possible.)
It is supposed to be able to allow you to sign into an account and access your onedrive, but if you try to sign in with an education account, for example, it comes up with this:
答案1
得分: 0
错误通常发生在您的应用程序支持的帐户类型为“仅个人Microsoft帐户”,但您尝试使用教育或工作场所帐户登录时。
我尝试在我的环境中复制相同的情况,并得到以下结果:
我注册了一个 Azure AD 应用程序,其支持的帐户类型
为“仅个人 Microsoft 帐户”,如下所示:
您可以像这样从应用程序的身份验证选项卡检查现有应用程序的支持的帐户类型
:
您还可以像下面这样检查应用程序清单文件中的**signInAudience
**值:
当我尝试用工作场所帐户而不是个人 Microsoft 帐户登录时,我得到了与您相同的错误,如下所示:
要解决这个错误,您需要修改应用程序的清单文件,更改支持的帐户类型
,像这样:
"signInAudience": "AzureADandPersonalMicrosoftAccount",
当我现在检查身份验证选项卡时,支持的帐户类型
已成功更改,如下所示:
如果错误仍然存在,请尝试注册一个新的 Azure AD 应用程序,选择如下支持的帐户类型
,然后再次重复整个过程:
英文:
> The error usually occurs if your application Supported account type is "Personal Microsoft accounts only" but you tried to sign in with education or workplace accounts.
I tried to reproduce the same in my environment and got the below results:
I registered one Azure AD application with Supported account type
as "Personal Microsoft accounts only" as below:
You can check Supported account type
of existing application from it's Authentication tab like this:
You can also check signInAudience
value in app's Manifest file like below:
When I tried to sign in with workplace account instead of personal Microsoft account, I got same error as you like below:
To resolve the error, you need to change Supported account type
of your application by modifying it's Manifest file like this:
"signInAudience": "AzureADandPersonalMicrosoftAccount",
When I checked Authentication tab now, Supported account type
changed successfully like below:
If the error still persists, try registering a new Azure AD application by selecting Supported account type
as below and repeat the whole process again:
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论