OneDrive上传工具在教育或工作场所账户上无法正常工作。

huangapple go评论75阅读模式
英文:

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,但如果您尝试使用教育帐户登录,例如,它会出现以下错误消息:

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:

OneDrive上传工具在教育或工作场所账户上无法正常工作。

答案1

得分: 0

错误通常发生在您的应用程序支持的帐户类型为“仅个人Microsoft帐户”,但您尝试使用教育或工作场所帐户登录时。 

我尝试在我的环境中复制相同的情况,并得到以下结果:

我注册了一个 Azure AD 应用程序,其支持的帐户类型为“仅个人 Microsoft 帐户”,如下所示:

OneDrive上传工具在教育或工作场所账户上无法正常工作。 

您可以像这样从应用程序的身份验证选项卡检查现有应用程序的支持的帐户类型

OneDrive上传工具在教育或工作场所账户上无法正常工作。 

您还可以像下面这样检查应用程序清单文件中的**signInAudience**值:

OneDrive上传工具在教育或工作场所账户上无法正常工作。 

当我尝试用工作场所帐户而不是个人 Microsoft 帐户登录时,我得到了与您相同的错误,如下所示:

OneDrive上传工具在教育或工作场所账户上无法正常工作。 

解决这个错误,您需要修改应用程序的清单文件,更改支持的帐户类型,像这样:

"signInAudience": "AzureADandPersonalMicrosoftAccount",

OneDrive上传工具在教育或工作场所账户上无法正常工作。 

当我现在检查身份验证选项卡时,支持的帐户类型已成功更改,如下所示:

OneDrive上传工具在教育或工作场所账户上无法正常工作。 

如果错误仍然存在,请尝试注册一个新的 Azure AD 应用程序,选择如下支持的帐户类型,然后再次重复整个过程:

OneDrive上传工具在教育或工作场所账户上无法正常工作。

英文:

> 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:

 OneDrive上传工具在教育或工作场所账户上无法正常工作。 

You can check Supported account type of existing application from it's Authentication tab like this: 

OneDrive上传工具在教育或工作场所账户上无法正常工作。 

You can also check signInAudience value in app's Manifest file like below:

 OneDrive上传工具在教育或工作场所账户上无法正常工作。 

When I tried to sign in with workplace account instead of personal Microsoft account, I got same error as you like below:

 OneDrive上传工具在教育或工作场所账户上无法正常工作。 

To resolve the error, you need to change Supported account type of your application by modifying it's Manifest file like this: 

"signInAudience": "AzureADandPersonalMicrosoftAccount",

OneDrive上传工具在教育或工作场所账户上无法正常工作。 

When I checked Authentication tab now, Supported account type changed successfully like below:

 OneDrive上传工具在教育或工作场所账户上无法正常工作。 

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:

 OneDrive上传工具在教育或工作场所账户上无法正常工作。

huangapple
  • 本文由 发表于 2023年2月18日 16:32:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/75492123.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定