Manoj
Manoj

Reputation: 3997

Unsupported app only token issue in authenticating office365

I have followed this link https://msdn.microsoft.com/en-us/office/office365/howto/building-service-apps-in-office-365 to set-up the Daemon or Server Application to Web API authentication method in Office365 to get access token.

The sample access token request is given below

POST https://login.microsoftonline.com/{tenant-id}/oauth2/token
grant_type : client_credentials
client_id : {clientId}
client_secret : {clientSecret}
resource : https://{tenant}.sharepoint.com

For Example:

https://login.microsoftonline.com/cae788bd-7a55-4fb5-9d1f-3aa5365e14a/oauth2/token
grant_type : client_credentials
client_id : 1dd0a211-06f1-4f6a-a232-b3a8dcab829b
client_secret : ZWtkWm9M5Ucx5j29UoXPy7GKG+Hu0eNdVFYO+lH761w=
resource : https://{tenant}.sharepoint.com

From the above api request, I am getting an access token, when I tried to create the folder or accessing any other api's from the above access token then it is showing an error as "Unsupported app only token". I have tried to call this webservices to get this error:

PUT https://{tenant}.sharepoint.com/_api/v1.0/Files/{parent-id}/children/{folder-name}
Authorization : BearerBearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik1uQ19WWmNBVGZNNXBPWWlKSE
Content-Type : application/json
Accept : application/json

But previously we have used the same Daemon or Server Application to Web API authentication method in Office365 to get access token and it was working fine.

And we have used the accesstoken to access the office 365 API's but now it is showing error as "Unsupported app only token".

Upvotes: 2

Views: 3784

Answers (1)

Marcel
Marcel

Reputation: 33

Manoj,

I got the App-only working in a WPF application for the Mail API, did you setup the certificate? According to the blog you mention

Because of the broad access these kinds of apps enjoy, there is an additional requirement for the app to successfully obtain an access token. Instead of using a client ID and client secret, the app must use an X.509 certificate with a public/private key pair.

See this link how to set it up: Performing app-only operations on SharePoint Online through Azure AD

Upvotes: 2

Related Questions