Specifies OAuth 2.0 specific details of the API used by the component. For more details about Authenticating with OAuth 2.0 please read the OAuth 2.0 specification .

Property Name Type Required Description
client_id string Yes The Consumer Key.
client_secret string Yes The Consumer Secret.
auth_uri string Yes URI to obtain User Authorization.
token_uri string Yes URI to obtain a Access Token.
scopes array of strings
Scope of the access request
prompt string

access_type string

Any object implementation is directly connected with one or several View Class definitions, therefore it is advisable to check them as well.

Examples of implementation

Here is an example of OAuth2 implementation in Google Spreadsheets component:

"oauth2":{
   "client_id":"{{GOOGLE_APP_ID}}",
   "client_secret":"{{GOOGLE_APP_SECRET}}",
   "auth_uri":"https://accounts.google.com/o/oauth2/v2/auth",
   "token_uri":"https://www.googleapis.com/oauth2/v4/token",
   "scopes": [
      "https://spreadsheets.google.com/feeds"
             ],
   "access_type": "offline",
   "prompt": "consent"
}

In some cases OAuth2 needs to receive some external parameters for accessing say production or sandbox environments. This kind of solution is implemented in our Salesforce component:

"credentials" : {
   "fields":{
      "prodEnv" : {
         "label":"Environment",
         "viewClass":"SelectView",
         "required":true,
         "model":{
            "test":"Sandbox",
            "login":"Production"
            },
         "prompt":"Select environment"
         },
         "oauth":{
            "label":"Authentication",
            "viewClass":"OAuthFieldView",
            "required": true
            }
        },
   "oauth2":{
      "client_id":"{{SALESFORCE_KEY}}",
      "client_secret":"{{SALESFORCE_SECRET}}",
      "auth_uri":"https://{{prodEnv}}.salesforce.com/services/oauth2/authorize",
      "token_uri":"https://{{prodEnv}}.salesforce.com/services/oauth2/token"
      }
}

auth_url can take additional parameters like this:

"oauth2": {
   "auth_uri": "https://login.windows.net/common/oauth2/authorize?resource={{encode resource}}",
   "token_uri": "https://login.windows.net/common/oauth2/token"
}