We are trying to establish a ProjectContext in order to read and update timephased actuals within Project Online using CSOM. To do this without security restrictions on the user credentials we are shooting for AppOnlyPermission.

We have accomplished the following:

  • Created a SharePoint Add-In in order to obtain a Client Id and Client Secret. There is no actual app for the add-in (see here for details: [Office 365 - Tenant Administrator - Trust Add In)

  • Create Access Token in our application using C#. Code:

    public static ProjectContext GetProjectContextWithAccessToken(string targetUrl, string accessToken)
        var projectContext = new ProjectContext(targetUrl)
            AuthenticationMode = ClientAuthenticationMode.Anonymous,
            FormDigestHandlingEnabled = false
        projectContext.ExecutingWebRequest +=
            delegate (object oSender, WebRequestEventArgs webRequestEventArgs) { webRequestEventArgs.WebRequestExecutor.RequestHeaders["Authorization"] = "Bearer " + accessToken; };
        return projectContext;
    public static ProjectContext GetProjectContext()
        var tenantAdminUri = new Uri(TenantSite);
        string realm = TokenHelper.GetRealmFromTargetUrl(tenantAdminUri);
        var token = TokenHelper.GetAppOnlyAccessToken(TokenHelper.SharePointPrincipal, tenantAdminUri.Authority, realm).AccessToken;
        return GetProjectContextWithAccessToken(ProjectSite, token);

Now, this is successful in getting a token, however, any calls we make using the project context returns a GeneralSecurityAccessDenied error.

The whole point to using the AppOnly Add-In is to avoid these security issues and yet here we are with security issues. Are we perhaps not loading to token correctly? Not applying to token to the project context correctly?

  • Did you ever find a solution to this? – Chris Romp Mar 15 '18 at 21:40
  • We abandoned this approach as we discovered that we are unable to achieve what we wanted even with AppOnly access. We do have a working solution using a different approach to transfer Timephased Data as well as other status updates. – Mark Corbin Mar 15 '18 at 23:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.