0
votes

Hi I am trying to develop native client app using managed activity api and I am trying to subscribe using following POST request

https://manage.office.com/api/v1.0/8bee0d59-7cb7-499f-aa59-8b6990061a96/activity/feed/subscriptions/start?contentType=Audit.AzureActiveDirectory

and getting following error {"Message":"Authorization has been denied for this request."}

Before this I did the Authentication and able to generate access token and used the tenantid retrieved from access token.Could Anyone please provide sample code or let me know how to get subscription Even referred the msdn docs but couldn't find the solution

1

1 Answers

0
votes

How did you acquire the access token? I can only reproduce this issue if I call the Office 365 management REST API using token of other resource(Office 365 or Microsoft Graph etc.)

You can refer to the request below to acquire the token for the Office 365 Management REST API(Authorization Code Grant Flow).

Step 1: Get auth code

Get: https://login.windows.net/common/oauth2/authorize?response_type=code&resource=https%3A%2F%2Fmanage.office.com&client_id={clientId}&redirect_uri={RedirectUrl}

Step 2: Request for the access token

POST: https://login.windows.net/common/oauth2/token
resource=https%3A%2F%2Fmanage.office.com&client_id={clientId}&redirect_uri={redirectUrl}&client_secret={clientSecret(if it is a confident app)}&grant_type=authorization_code&code={AuthCode}

More detail about the progress to get the token, you can refer to here