久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Graph API - 權(quán)限不足,無法完成操作

Graph API - Insufficient privileges to complete the operation(Graph API - 權(quán)限不足,無法完成操作)
本文介紹了Graph API - 權(quán)限不足,無法完成操作的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

限時(shí)送ChatGPT賬號..

當(dāng)我嘗試訪問圖形服務(wù)客戶端時(shí)收到錯(cuò)誤消息:

When trying to access the Graph Service Client using I am receiving the error :

代碼:Authorization_RequestDenied
消息:權(quán)限不足,無法完成操作.

Code: Authorization_RequestDenied
Message: Insufficient privileges to complete the operation.

研究此錯(cuò)誤后,最常見的解決方案是為 API 設(shè)置權(quán)限.這已經(jīng)完成并且有權(quán)讀取基本/完整配置文件.

After researching this error the most common solution was to set the permissions for the API. This had already been done and has permissions to read basic/full profiles.

我已刪除并重新添加了 API.

I've delete and re-added the APIs.

下面是我的 AzureAuthenticationProvider 類中的代碼,它繼承自 IAuthenticationProvider:

Below is the code in my AzureAuthenticationProvider class which inherits from IAuthenticationProvider:

public class AzureAuthenticationProvider : IAuthenticationProvider
{
    private string _azureDomain = "myDevDom.onmicrosoft.com";

    public async Task AuthenticateRequestAsync(HttpRequestMessage request)
    {
        try
        {
            string clientId = "2b823c67-1b0d-4a10-a9e1-737142516f5q";
            string clientSecret = "xxxxxx";

            AuthenticationContext authContext = new AuthenticationContext("https://login.windows.net/" + _azureDomain + "/oauth2/token");

            ClientCredential credentials = new ClientCredential(clientId, clientSecret);

            AuthenticationResult authResult = await authContext.AcquireTokenAsync("https://graph.microsoft.com/", credentials);

            request.Headers.Add("Authorization", "Bearer " + authResult.AccessToken);
        }
        catch (Exception ex)
        {
        }
    }
}

我嘗試將客戶端密鑰更改為無效的 ID,但它引發(fā)了錯(cuò)誤,因此客戶端密鑰是正確的.我還嘗試通過更改訪問令牌來驗(yàn)證訪問令牌是否有效,這也會返回錯(cuò)誤.

I've tried changing the client secret to an invalid Id and it threw an error, so the client key is correct. I've also tried to verify that the access token is valid by altering the access token, this also returns a error.

上面的代碼似乎工作正常.

The above code seems to work fine.

下面是我嘗試訪問 Azure AD 的代碼:

Below is the code where I'm trying to access Azure AD:

public async Task<IGraphServiceUsersCollectionPage> GetUsersByLastName(string lastname)  
{
    GraphServiceClient graphClient = new GraphServiceClient(new AzureAuthenticationProvider());
    string filter = String.Format("startswith(surname, '{0}')", lastname);
    IGraphServiceUsersCollectionPage users = await graphClient.Users.Request().Filter(filter).GetAsync(); //Fails on this line
    return users;
}

非常感謝任何幫助,并提前感謝您的幫助.

Any help is much appreciated, and thanks in advance for any help.

推薦答案

請參考以下步驟:

  1. 從您的屏幕截圖中,您似乎授予了 Windows Azure Active Directory(azure ad graph api) 的 Read and write directory data 應(yīng)用程序權(quán)限.由于您使用的是 microsoft graph (

  1. From your screenshot , seems you grant Read and write directory data application permission for Windows Azure Active Directory(azure ad graph api) . Since you are using microsoft graph (https://graph.microsoft.com/) , you need to grant application permission for Microsoft Graph :

由于您是 AAD 中的管理員,您可以通過單擊上面屏幕截圖中顯示的 Grant permission 按鈕為組織中的用戶授予權(quán)限.

Since you are admin in your AAD, You could grant permission for users in organization by click Grant permission button shown in above screenshot .

然后您可以使用您的代碼(客戶端憑據(jù)流來獲取令牌)并查詢用戶信息.如果您檢查 azure ad 頒發(fā)的訪問令牌中的聲明,您可以在 roles 聲明中找到 Directory.Read.All 權(quán)限.

Then you could use your code (client credential flow to get the token) and query users information . If you check the claims in access token issued by azure ad , you could find Directory.Read.All permission in roles claim .

這篇關(guān)于Graph API - 權(quán)限不足,無法完成操作的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

ASP.NET Core authenticating with Azure Active Directory and persisting custom Claims across requests(ASP.NET Core 使用 Azure Active Directory 進(jìn)行身份驗(yàn)證并跨請求保留自定義聲明)
ASP.NET Core 2.0 Web API Azure Ad v2 Token Authorization not working(ASP.NET Core 2.0 Web API Azure Ad v2 令牌授權(quán)不起作用)
ASP Core Azure Active Directory Login use roles(ASP Core Azure Active Directory 登錄使用角色)
How do I get Azure AD OAuth2 Access Token and Refresh token for Daemon or Server to C# ASP.NET Web API(如何獲取守護(hù)進(jìn)程或服務(wù)器到 C# ASP.NET Web API 的 Azure AD OAuth2 訪問令牌和刷新令牌) - IT屋-程序員軟件開發(fā)技
.Net Core 2.0 - Get AAD access token to use with Microsoft Graph(.Net Core 2.0 - 獲取 AAD 訪問令牌以與 Microsoft Graph 一起使用)
Azure KeyVault Active Directory AcquireTokenAsync timeout when called asynchronously(異步調(diào)用時(shí) Azure KeyVault Active Directory AcquireTokenAsync 超時(shí))
主站蜘蛛池模板: 91精品入口蜜桃 | 一区二区三区四区在线视频 | 国产精品国产精品国产专区不卡 | 日韩精品福利 | 91国产精品 | 男女下面一进一出网站 | 日韩精品三区 | 亚洲 欧美 日韩 在线 | 亚洲精品久久久久久久久久久久久 | 日日夜夜免费精品视频 | 日本精品一区 | 91国产精品 | 色婷婷综合久久久中字幕精品久久 | 91久久视频 | 国产精品免费看 | 免费黄色成人 | 精品成人一区二区 | www久久国产 | 国产成人99久久亚洲综合精品 | av国产精品 | 精品日韩一区 | 国产一区二区三区视频 | 成年网站在线观看 | 久久精品高清视频 | 五月槐花香 | 国产高清在线精品一区二区三区 | 天堂成人国产精品一区 | 久久久91 | 久久这里有精品 | 亚洲欧美bt | 国产午夜精品视频 | 99国产精品久久久 | 色888www视频在线观看 | 亚洲成人一区二区三区 | 视频一二区 | 亚洲一区二区三区在线 | 羞羞视频免费观 | 日韩欧美在线观看 | 欧美久久一区 | 91久久国产综合久久 | 久久国产亚洲精品 |