简体   繁体   中英

Sharepoint online - Token type is not allowed

I'm trying to fetch all my projects and tasks from Microsoft project PWA using: https://.sharepoint.com/sites/pwa/_api/ProjectData/Projects. I managed to get my bearer token following some documentation and added it to the header of this route. But i'm receiving the following error: "error": "invalid_request", "error_description": "Token type is not allowed."

I faced the same issue and the following comment on another forum helped me. The following is just a copy of what was messaged there.

For a new SharePoint subscription, Grant App Permission is disabled by default or the browser link https://xxxx-admin.sharepoint.com/_layouts/15/appinv.aspx is disabled. To enable this feature, we need to connect to SharePoint using Windows PowerShell and then run set-spotenant -DisableCustomAppAuthentication $false.

Run the following commands on PowerShell.

Install-Module -Name Microsoft.Online.SharePoint.PowerShell
$adminUPN="<the full email address of a SharePoint administrator account, example: jdoe@contosotoycompany.onmicrosoft.com>"
$orgName="<name of your Office 365 organization, example: contosotoycompany>"
$userCredential = Get-Credential -UserName $adminUPN -Message "Type the password."
Connect-SPOService -Url https://$orgName-admin.sharepoint.com -Credential $userCredential
set-spotenant -DisableCustomAppAuthentication $false

Please note:

Fill in the values for the $adminUPN and $orgName variables (replacing all the text between the quotes, including the < and > characters), and then run the following commands at the SharePoint Online Management Shell command prompt:

When prompted with the Windows PowerShell credential request dialog box, type the password for the SharePoint admin account.

Afterward, run https://xxxx-admin.sharepoint.com/_layouts/15/appinv.aspx to grant permission

Generate new token and CRUD operations using REST API on SharePoint should be working by now.

Additional link: https://docs.microsoft.com/en-us/powershell/sharepoint/sharepoint-online/connect-sharepoint-online?view=sharepoint-ps

I think, there are multiple issues when using Powershell in the Mac environment to handle SharePoint. You can try out m365 nodejs client as well. This was work fine for me in a Mac environment. You can download it with the following command:

 npm i -g @pnp/cli-microsoft365

The command would be as follows to disable custom app authentication:

 m365 spo tenant settings set --DisableCustomAppAuthentication false
Hope this would help.

https://pnp.github.io/cli-microsoft365/cmd/spo/tenant/tenant-settings-set/

https://pnp.github.io/cli-microsoft365/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM