OAuth Token Generation

Background Information about OAuth

See this Wikipedia article for background information about OAuth:

https://en.wikipedia.org/wiki/OAuth

Invoking P6 REST API hosted on Oracle Cloud Infrastructure (oraclecloud.com)

In order to invoke the P6 REST API hosted on Oracle Cloud Infrastructure, first generate an OAuth token using Basic authentication, then you use the OAuth token to access the API.

Accessing P6 REST API using Standard and OAuth Authentication

The Standard authentication scheme uses Base64 encoded value of "user:password".

The Bearer authentication scheme uses an OAuth token.

  • To access APIs using Standard authentication, the user needs to provide Base64 encoded value of "user:password"
  • To access APIs using OAuth, the user needs to provide a Bearer token.

OAuth token generation using Standard Authentication

Use the endpoint, as shown below, to generate an OAuth access token to use for accessing the API. This endpoint can be invoked with Standard authentication of a valid Base64 encoded value of "user:password" on Oracle Cloud Infrastructure that has been provisioned into P6.

Scope must be the full path (always http) to the context root of the application - http://<server URL>/p6ws/restapi.

Example using CURL

curl -X POST "https://<server URL>/p6ws/oauth/token" \ 
      -H "authToken" : Base64 encoded value of "user:password" 
      -H "token_exp": "3600"\
 

  • <Base64-Encoded-value-of-user-password>: The Base64 encoded value of "user:password".
    • Use the curl command to encode: "$(echo -n user-name:password | base64)"

Response Payload

Raw <OAuth-Access-Token> token will be returned as part of Response payload.

Example Using a REST Client

POST https://<server URL>/p6ws/oauth/token

In Headers:

-H "authToken" : Base64 encoded value of "user:password" 
      -H "token_exp": "3600"

Response:

Raw <OAuth-Access-Token> token will be returned as part of Response payload.

Using the OAuth generated OAuth token to invoke the P6 REST API using Bearer Authentication

Using the access token generated using Basic authentication, along with the header 'x-prime-identity-app', P6 REST API can be invoked as shown below.

Using curl

curl - X GET\ "https://<Primavera host>/p6ws/restapi/project?Fields=Name 
 - H "Authorization: Bearer <OAuth-Access-Token>"\ 
 - H "Content-Type: application/json"\ 

Using a REST Client

GET: https://<Primavera host>/p6ws/restapi/project?Fields=Name
 Authorization: Bearer <OAuth-Access-Token>