Answered by:
Project Online OData using Access Tokens

Question
-
I have built a SharePoint provider-hosted app that retrieves data from Project Online.
I'm struggling with accessing the Project Online OData feed at /_api/ProjectData without having to specify a user's credentials like all the samples (since I want this published to the Store).
As I understand it OData doesn't support app-only access tokens, so I get a user+add-in access token using this method.
//Get user+add-in access token. string accessToken = TokenHelper.GetAccessToken(contextToken, sharepointUrl.Authority).AccessToken;
I can use that token to make CSOM calls successfully so I know the token is valid, the user that installed my provider-hosted app has the necessary Project permissions, and the app manifest is setup correctly.
However, when I try to use that same token in a simple WebClient to make OData REST calls by adding the token to my header:
client.Headers[HttpRequestHeader.Authorization] = $"Bearer {accessToken}";
I always get: (403) Forbidden
Can anyone shed some light on this? Or point me to an example that uses access tokens to access OData instead of user credentials?
Thanks,
Mike
Answers
-
Hi Mike,
As far as I know, the ProjectOdata endpoint does require username and password to be used to authenticate, it has not been implemented the same way as the other Project PWA endpoints.
Paul
Paul Mather | Twitter | http://pwmather.wordpress.com | CPS | MVP | Downloads
- Marked as answer by PWMatherMVP Thursday, November 22, 2018 12:33 PM
All replies
-
Hi Mike,
As you have found, the ProjectData OData API doesn't support app only auth and does require user credentials - I dont think you will find away around this but let us know if you do / have done already.
Paul
Paul Mather | Twitter | http://pwmather.wordpress.com | CPS | MVP | Downloads
-
Hey Paul-
It was suggested I need a FormDigestValue but haven't been able to get that working either.
Here's my test controller if you have any other ideas.
Thanks,
Mike -
Hi Mike,
As far as I know, the ProjectOdata endpoint does require username and password to be used to authenticate, it has not been implemented the same way as the other Project PWA endpoints.
Paul
Paul Mather | Twitter | http://pwmather.wordpress.com | CPS | MVP | Downloads
- Marked as answer by PWMatherMVP Thursday, November 22, 2018 12:33 PM
-
Hi Paul,
we are a provider of integrated systems and we would like to use our standard programming methods to access PWA data ODATA using an Access Token from a web service, as seems to be a standard by many integrators.
Is there a way of expediting a request through Microsoft to support this requirement?
Best Regards
Stewart
-
Hi Stewart,
We have the same limitation in one of our Applications, we have to pass in a username and password as part of the OAuth auth flow when accessing the Project Online Reporting API (_api/ProjectData). I'm not sure how you can put this request to Microsoft, the best route is via the Uservoice like you have here: https://microsoftproject.uservoice.com/forums/218133-microsoft-project/suggestions/36983071-access-project-online-pwa-odata-data-using-an-acce but it needs lots of votes to get noticed so Microsoft see there is a demand for this.
Paul
Paul Mather | Twitter | http://pwmather.wordpress.com | CPS | MVP | Downloads