Graph API - How to list site drives on GCC High Environment?

Zachary Shane 26 Reputation points
2022-10-06T14:19:07.853+00:00

How can I list a SharePoint site's drives using the Graph API for GCC High environments? It works when using the same endpoint in my standard environment. I'm able to list all of the drives. However, in my client's GCC High environment, with the same exact API Permissions on the App Registration in Azure, I can't get it to list anything. It just returns an empty array with a 200 status.

Graph API Endpoint: https://graph.microsoft.us/v1.0/sites/{{site-id}}/drives

Response:

{  
    "@odata.context": "https://graph.microsoft.us/v1.0/$metadata#drives",  
    "value": []  
}  

API Permissions
248070-image.png

This endpoint will return the site's metadata however: https://graph.microsoft.us/v1.0/sites/{{site-id}}

    {  
        "@odata.context": "https://graph.microsoft.us/v1.0/$metadata#sites/$entity",  
        "createdDateTime": "2022-10-05T17:42:12.63Z",  
        "description": "",  
        "id": "{{site-id}}",  
        "lastModifiedDateTime": "2022-10-06T10:13:56Z",  
        "name": "DocumentCenter",  
        "webUrl": "{{site-url}}",  
        "displayName": "{{site-name}}",  
        "root": {},  
        "siteCollection": {  
            "hostname": "{{host-name}}"  
        }  
    }  
Microsoft Security | Microsoft Entra | Microsoft Entra ID
Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Zachary Shane 26 Reputation points
    2022-10-27T13:49:31.303+00:00

    After speaking with a Microsoft support specialist I found that my "Grant Type" within my Authorization settings in Postman were incorrect. I was using an Authorization Code, and I needed to use Client Credentials. My App Registration had Application permissions, not Delegated for the SharePoint permissions. So the call was not authorized to return SharePoint lists until I switched to the Client Credential Grant Type.

    254794-8zt9d.png

    Also, anyone trying to do this in an Azure Function with the Graph Client SDK, you will need to use a Custom HTTP Client.

            // using environment variables in local.settings.json for auth  
            var tenantId = Environment.GetEnvironmentVariable("AzureADAppTenantId");  
            var clientSecret = Environment.GetEnvironmentVariable("AzureADAppSecret");  
            var clientId = Environment.GetEnvironmentVariable("AzureADAppClientId");  
            // need to pass in a null auth provider so SDK uses token in header  
            IAuthenticationProvider authenticationProvider = null;  
            // create the http client using null provider  
            var client = GraphClientFactory.Create(authenticationProvider, "v1.0", GraphClientFactory.USGOV_Cloud);  
            // set the scope for the client calls  
            var scope = "https://graph.microsoft.us/v1.0/";  
            // create the scopes for us domain  
            List<string> scopes = new List<string>() { "https://graph.microsoft.us/.default" };  
            // create the client app  
            IConfidentialClientApplication app = ConfidentialClientApplicationBuilder.Create(clientId)  
                .WithClientSecret(clientSecret)  
                .WithTenantId(tenantId)  
                .WithAuthority("https://login.microsoftonline.us/" + tenantId)  
                .Build();  
      
            // wait for the token  
            AuthenticationResult authenticationResult = await app.AcquireTokenForClient(scopes).ExecuteAsync();  
            // set the token  
            var token = authenticationResult.AccessToken;  
            // add the auth headers to the client  
            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);  
            // initialize the graph client  
            var graphClient = new GraphServiceClient(client, scope);  
    
            // now get the drives  
            var drives = await graphClient.Sites[siteId].Drives.Request().GetAsync();
    
    1 person found this answer helpful.

  2. James Hamil 27,221 Reputation points Microsoft Employee Moderator
    2022-10-06T19:54:58.443+00:00

    Hi @Zachary Shane , according to this document:

    "Graph functionality within SharePoint Online for GCC High is currently disabled. Any service that relies on Microsoft Graph may not currently be available"

    I'm not sure why this is but I can reach out about any questions you have. I'm sorry about this! Please let me know what questions you have and I can help you further.

    Thank you,
    James


  3. Zehui Yao_MSFT 5,876 Reputation points
    2022-10-07T10:05:24.657+00:00

    Hi @Zachary Shane , Since this feature is presently not available, you can submit a feature request idea using this support link,
    which will be monitored by Microsoft team and make the enhancements to Microsoft Graph APIs. I will also upvote for you.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.