Skip to content

SharePoint Online API: Access denied creating Personal Site when passing Signed In User Bearer Token #4673

@garrytrinder

Description

@garrytrinder

Category

  • Question
  • Typo
  • Bug
  • Additional article idea

Expected or Desired Behavior

The below HTTP call should create a new personal site for the user

POST /_vti_bin/client.svc/ProcessQuery HTTP/1.1
Host: tenant-admin.sharepoint.com
Content-Type: application/xml
Authorization: Bearer <token>

<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="SharePoint PnP PowerShell Library" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009">
    <Actions>
        <ObjectPath Id="5" ObjectPathId="4" />
        <Method Name="CreatePersonalSiteEnqueueBulk" Id="6" ObjectPathId="4">
            <Parameters>
                <Parameter Type="Array">
                    <Object Type="String">[email protected]</Object>
                </Parameter>
            </Parameters>
        </Method>
    </Actions>
    <ObjectPaths>
        <StaticMethod Id="4" Name="GetProfileLoader"  TypeId="{9c42543a-91b3-4902-b2fe-14ccdefb6e2b}" />
    </ObjectPaths>
</Request>

Observed Behavior

Above request results in 200 OK response but returns the below error, no personal site is created for the user.

[
    {
        "SchemaVersion": "15.0.0.0",
        "LibraryVersion": "16.0.19318.12002",
        "ErrorInfo": {
            "ErrorMessage": "Access denied. You do not have permission to perform this action or access this resource.",
            "ErrorValue": null,
            "TraceCorrelationId": "7c05089f-70d6-1000-af48-5aaa8564ad67",
            "ErrorCode": -2147024891,
            "ErrorTypeName": "System.UnauthorizedAccessException"
        },
        "TraceCorrelationId": "7c05089f-70d6-1000-af48-5aaa8564ad67"
    }
]

Steps to Reproduce

  • Create Azure AD application
  • Set the following delegate SharePoint Online API permissions
    • AllSites.FullControl
    • User.ReadWrite.All
  • Grant Admin consent for delegated permissions
  • Generate Bearer Token using OAuth 2.0 Authorization Code Flow
    • Provide Tenant Admin credentials
  • Pass Bearer Token in Authorisation header of request

Related Issues

pnp/PnP-PowerShell#2267
OneDrive/onedrive-api-docs#530
pnp/cli-microsoft365#929

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: Attention 👋Original poster responded to request for feedback, awaiting attention from Microsoft / community.area:csom/rest/apiCategory: SharePoint Client Side Object Model SDK / REST APIstatus:to-be-reviewedIssue needs to be reviewed by Microsoft for additional follow up / review.type:archive-old-issueIssues which are closed as tool old for active work

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions