SharePoint REST API Authentication Token

James 41 Reputation points
2022-01-04T22:28:47.867+00:00

Hey guys,

I have got an access token using the endpoint "https://login.microsoftonline.com/common/oauth2/v2.0/token".

I now wish to use the endpoint " https://{{your_tenant}}.sharepoint.com/_api/SPSiteManager/Create" in order to create a site. Do I need to use the refresh token to get a SharePoint specific auth token or should the access I received above be able to access this endpoint?

Thanks,

James

Microsoft 365 and Office SharePoint Development
Microsoft 365 and Office SharePoint For business Windows
{count} votes

2 answers

Sort by: Most helpful
  1. RaytheonXie_MSFT 40,471 Reputation points Microsoft External Staff
    2022-01-05T07:45:36.42+00:00

    Hi @James ,
    I will recommend you to grant access using SharePoint App-Only to get the Authentication Token. You could use following App's Permission Request XML to grant client id sites collection level permission

    <AppPermissionRequests AllowAppOnlyPolicy="true">  
        <AppPermissionRequest Scope="http://sharepoint/content/sitecollection" Right="FullControl" />  
    </AppPermissionRequests>  
    

    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.



  2. Clarence Tunstall 21 Reputation points
    2022-10-20T05:52:13.79+00:00

    I'm trying to follow these steps and it worked until the final step where it encountered an error and I followed these steps to the letter. WHen I used Scope="http://sharepoint/content/sitecollection, I got an error. When I used Scope="http://sharepoint/content/tenant under my sharepoint site's admin section it worked, but I didn't see the app under app permissions to get the id for the token.

    0 comments No comments

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.