You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -74,7 +74,7 @@ After authentication has completed, the access token is stored on the `ApiClient
74
74
75
75
The Client Credentials grant only works when used in node.js. This is restricted intentionally because it is impossible for client credentials to be handled securely in a browser application.
@@ -94,7 +94,7 @@ Optional parameters may be specified in the optional third parameter for `loginI
94
94
95
95
*`state` - An arbitrary string used to associate a login request with a login response. This value will be provided in the `state` property on the object when the promise is resolved. The state in the resolved promise will be identical to what was passed into `loginImplicitGrant`, except when the state is retrieved from the auth hash upon completing a login; in that case, the state from the auth hash will override the passed in state.
96
96
97
-
~~~javascript
97
+
```{"language":"javascript"}
98
98
const client = platformClient.ApiClient.instance;
99
99
client.loginImplicitGrant(clientId, redirectUri, { state: state })
100
100
.then((data) => {
@@ -105,35 +105,35 @@ client.loginImplicitGrant(clientId, redirectUri, { state: state })
105
105
// Handle failure response
106
106
console.log(err);
107
107
});
108
-
~~~
108
+
```
109
109
110
110
**Any platform** Provide an existing auth token
111
111
112
-
~~~javascript
112
+
```{"language":"javascript"}
113
113
const client = platformClient.ApiClient.instance;
114
114
client.setAccessToken(yourAccessToken);
115
115
// Do authenticated things; no authentication function needed
116
-
~~~
116
+
```
117
117
118
118
119
119
## Environments
120
120
121
121
If connecting to a PureCloud environment other than mypurecloud.com (e.g. mypurecloud.ie), set the environment on the `ApiClient` instance.
122
122
123
-
~~~js
123
+
```{"language":"javascript"}
124
124
const client = platformClient.ApiClient.instance;
125
125
client.setEnvironment('mypurecloud.ie');
126
-
~~~
126
+
```
127
127
128
128
129
129
## Access Token persistence
130
130
131
131
In a web environment, it is possible to persist the access token to prevent an authentication request from being made on each page load. To enable this function, simply enable settings persistence prior to attempting a login. To maintain multiple auth tokens in storage, specify the prefix to use for storage/retrieval when enabling persistence. Otherwise, the prefix is optional and will default to `purecloud`.
By default, the SDK will return only the response body as the result of an API function call. To retrieve additional information about the response, enable extended responses. This will return the extended response for all API function calls:
191
191
192
-
~~~js
192
+
```{"language":"javascript"}
193
193
const client = platformClient.ApiClient.instance;
194
194
client.setReturnExtendedResponses(true);
195
-
~~~
195
+
```
196
196
197
197
Extended response object example (`body` and `text` have been truncated):
198
198
199
-
~~~json
199
+
```{"language":"json"}
200
200
{
201
201
"status": 200,
202
202
"statusText": "",
@@ -214,7 +214,7 @@ Extended response object example (`body` and `text` have been truncated):
214
214
"text": "",
215
215
"error": null
216
216
}
217
-
~~~
217
+
```
218
218
219
219
220
220
### Using a Proxy (Node.js only)
@@ -228,7 +228,7 @@ After both steps have been completed, the configured proxy server will be used f
228
228
229
229
NOTE: SDK proxy configuration is only available in the node.js package due to `superagent-proxy`'s incompatibility with browserify. Additionally, `superagent-proxy` is not included a dependency of the SDK and must be provided by your node application's dependencies.
230
230
231
-
~~~js
231
+
```{"language":"javascript"}
232
232
const client = platformClient.ApiClient.instance;
233
233
require('superagent-proxy')(client.superagent);
234
234
// Configure settings for your proxy here
@@ -238,7 +238,7 @@ client.proxy = {
238
238
port: 443,
239
239
protocol: 'https',
240
240
};
241
-
~~~
241
+
```
242
242
243
243
244
244
### Error Responses
@@ -247,7 +247,7 @@ Error responses will always be thrown as an extended response object. Note that
247
247
248
248
Example error response object:
249
249
250
-
~~~json
250
+
```{"language":"json"}
251
251
{
252
252
"status": 404,
253
253
"statusText": "",
@@ -274,17 +274,17 @@ Example error response object:
274
274
"original": null
275
275
}
276
276
}
277
-
~~~
277
+
```
278
278
279
279
280
280
## Debug Logging
281
281
282
282
There are hooks to trace requests and responses. To enable debug tracing, provide a log object. Optionally, specify a maximum number of lines. If specified, the response body trace will be truncated. If not specified, the entire response body will be traced out.
0 commit comments