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
The _loginPKCEGrant_ only works when used in a browser. This is because a node.js application does not have a browser interface that can display the Genesys Cloud login window.
188
+
189
+
Optional parameters may be specified in the optional third parameter for `loginPKCEGrant`. This parameter accepts an object with key/value pairs. Supported properties:
190
+
191
+
*`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 `loginPKCEGrant`, except when the state is retrieved from the auth query upon completing a login; in that case, the state from the auth query will override the passed in state.
192
+
193
+
The _loginPKCEGrant_ supports an optional fourth parameter for `loginPKCEGrant`. This parameter accepts a string, used to provide a code verifier as input. When no code verifier is provider (Method 1), the SDK automatically generates a PKCE Code Verifier and saves it in _window sessionStorage_. If a code verifier is provided (Method 2), it is up to the custom application to store the code verifier value and pass it in _loginPKCEGrant_.
194
+
195
+
```javascript
196
+
constclient=platformClient.ApiClient.instance;
197
+
198
+
// Method1: Let loginPKCEGrant generate the code verifier
199
+
client.loginPKCEGrant(clientId, redirectUri, { state: state })
200
+
.then((data) => {
201
+
console.log(data);
202
+
// Do authenticated things
203
+
})
204
+
.catch((err) => {
205
+
// Handle failure response
206
+
console.log(err);
207
+
});
208
+
209
+
// Method2: code verifier as input parameter
210
+
let codeVerifier =client.generatePKCECodeVerifier(128);
211
+
client.loginPKCEGrant(clientId, redirectUri, { state: state }, codeVerifier)
212
+
.then((data) => {
213
+
console.log(data);
214
+
// Do authenticated things
215
+
})
216
+
.catch((err) => {
217
+
// Handle failure response
218
+
console.log(err);
219
+
});
220
+
```
221
+
222
+
The SDK also provides methods to generate a PKCE Code Verifier and to compute PKCE Code Challenge.
223
+
224
+
```javascript
225
+
let codeVerifier =client.generatePKCECodeVerifier(128);
226
+
let codeChallenge =awaitclient.computePKCECodeChallenge(codeVerifier);
The Implicit grant only works when used in a browser. This is because a node.js application does not have a browser interface that can display the Genesys Cloud login window.
0 commit comments