Request a Transaction with OAuth 2.0
After your application has requested and received an access token, it can use the access token to authenticate itself while requesting transactions. The following points illustrate use-cases that require authentication and give sample code to illustrate using the OAuth access token to provide that authentication.
Use a Data Query or Embedding a Visual
To use a data query or to embed a Composer visual in your own web application, you must use Composer's JavaScript client library to create a Composer client. Creating a client requires code like this:
ZoomdataSDK.createClient({ credentials: credentialConfig, application: applicationConfig })
Composer allows its security configuration object to contain either a source-based security key or an OAuth access token, but not both. In the example above, the security configuration object is associated with the credentials
key using the variable name
credentialConfig
. The example below shows a security configuration object that uses an OAuth token rather than a Composer security key.
var credentialsConfig = { access_token: '8615a80b-28c0-4521-930f-5ab6f26d3686' };
Use cURL
You can naturally use cURL or the library of your choice to request a transaction using OAuth 2.0. For example:
curl -X GET https://<yourserver/composer>/api/<users/123456789>
-H "Content-Type: application/vnd.composer.v2+json; Authorization: Bearer <ff16372e-38a7-4e29-88c2-1fb92897f558> "
in which:
<yourserver/zoomdata>
is the DNS and path for your Composer server, using the correct protocol.<users/123456789>
is replaced with the method and parameters that you wish to useAuthorization
parameter contains your own access token
Comments
0 comments
Please sign in to leave a comment.