簡體   English   中英

MS Graph身份驗證問題

[英]MS Graph authentication issue

我的公司有一個基於WordPress的Intranet,我們使用Office365。 我希望作為一個全局應用程序(未經用戶明確同意)加入到圖中以獲取數據。 我已經使其全部工作,但是/ users / user_name / calendarview端點遇到了問題。

我可以使用以下方法獲取有效的訪問令牌:

$auth_request_body = http_build_query( array(
    'grant_type' => 'client_credentials',
    'client_id' => CLIENT_ID,
    'client_secret' => SECRET_KEY,
    'resource' => 'https://graph.microsoft.com/'
) );

$response = wp_remote_post( $url, array(
    'body' => $auth_request_body
) );

$body = json_decode( wp_remote_retrieve_body( $response ) );

$token_type = $body->token_type;
$access_token = $body->access_token;

並且可以多次成功的調用,例如在https://graph.microsoft.com/v1/users/user_name端點或到https://graph.microsoft.com/v1/groups/group_id當試圖端點,然而到達https://graph.microsoft.com/v1/users/user_id/calendarview端點,我得到以下響應:

[body] => {
    "error": {
        "code": "ErrorAccessDenied",
        "message": "Access is denied. Check credentials and try again.",
        "innerError": {
            "request-id": request_id,
            "date": "2018-08-08T21:57:50"
        }
     }
 }
 [response] => Array
    (
        [code] => 403
        [message] => Forbidden
    )

我正在本地環境中工作,出於測試目的,我已將所有應用程序/委派的權限授予了本地計算機(我認為..我仍然不太積極如何確保新磨碎的權限在本地計算機上生效)。

有什么想法嗎?

... 沒關系。

顯然,我新委派的權限尚未生效。 上面的這種方法確實適用於我的方案。

我認為您應該確認是否向應用程序授予適當的權限。 在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM