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

Graph API - 權限不足,無法完成操作

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

問題描述

限時送ChatGPT賬號..

當我嘗試訪問圖形服務客戶端時收到錯誤消息:

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

代碼:Authorization_RequestDenied
消息:權限不足,無法完成操作.

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

研究此錯誤后,最常見的解決方案是為 API 設置權限.這已經完成并且有權讀取基本/完整配置文件.

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,但它引發了錯誤,因此客戶端密鑰是正確的.我還嘗試通過更改訪問令牌來驗證訪問令牌是否有效,這也會返回錯誤.

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 應用程序權限.由于您使用的是 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 按鈕為組織中的用戶授予權限.

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

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

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 .

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

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

相關文檔推薦

ASP.NET Core authenticating with Azure Active Directory and persisting custom Claims across requests(ASP.NET Core 使用 Azure Active Directory 進行身份驗證并跨請求保留自定義聲明)
ASP.NET Core 2.0 Web API Azure Ad v2 Token Authorization not working(ASP.NET Core 2.0 Web API Azure Ad v2 令牌授權不起作用)
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(如何獲取守護進程或服務器到 C# ASP.NET Web API 的 Azure AD OAuth2 訪問令牌和刷新令牌) - IT屋-程序員軟件開發技
.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(異步調用時 Azure KeyVault Active Directory AcquireTokenAsync 超時)
主站蜘蛛池模板: 精品91久久 | 亚洲午夜av久久乱码 | 成人做爰999 | www.欧美视频 | 国产资源在线播放 | 亚洲国产精品日本 | 亚洲精品在线免费观看视频 | 欧美成人a | 欧美精品久久久久 | 欧美激情国产精品 | 成人亚洲精品 | 国产精品一区二区三区免费观看 | av一区二区三区四区 | 成人永久免费 | 黄色一级视频免费 | 91香蕉| 91影院在线观看 | 综合久久99 | 久久久精品一区 | 国产成人精品久久 | 韩国精品一区 | 亚洲国产精品一区二区久久 | 欧美精品一区在线 | 日韩三区在线 | 91久久视频 | 黄色片网此 | 国产一区二区影院 | 欧美男人的天堂 | 亚洲天堂一区 | 婷婷中文在线 | 91爱爱·com | 久久亚洲国产精品 | 日韩av在线中文字幕 | 成人毛片在线视频 | 欧美a v在线| 一区二区三区四区视频 | 欧美日韩视频在线第一区 | 一区二区欧美在线 | 91麻豆精品国产91久久久资源速度 | 欧美精品一区二区三区在线播放 | 亚洲一区在线播放 |