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
* import * as contentstack from '@contentstack/management'
16
16
* const client = contentstack.client();
@@ -80,7 +80,8 @@ export default class OAuthHandler {
80
80
* @description Authorize the user by redirecting to the OAuth provider's authorization page
81
81
* @memberof OAuthHandler
82
82
* @func authorize
83
-
* @returns {any} Authorization URL
83
+
* @async
84
+
* @returns {Promise<string>} Promise that resolves to authorization URL
84
85
* @example
85
86
* import * as contentstack from '@contentstack/management'
86
87
* const client = contentstack.client();
@@ -114,8 +115,9 @@ export default class OAuthHandler {
114
115
* @description Exchange the authorization code for an access token
115
116
* @memberof OAuthHandler
116
117
* @func exchangeCodeForToken
117
-
* @param {any} code - Authorization code received from the OAuth provider
118
-
* @returns {any} Token data
118
+
* @async
119
+
* @param {string} code - Authorization code received from the OAuth provider
120
+
* @returns {Promise<Object>} Promise that resolves to token data object
119
121
* @example
120
122
* import * as contentstack from '@contentstack/management'
121
123
* const client = contentstack.client();
@@ -155,9 +157,10 @@ export default class OAuthHandler {
155
157
* @description Refreshes the access token using the provided refresh token or the one stored in the axios instance.
156
158
* @memberof OAuthHandler
157
159
* @func refreshAccessToken
160
+
* @async
158
161
* @param {string|null} [providedRefreshToken=null] - The refresh token to use for refreshing the access token. If not provided, the stored refresh token will be used.
159
-
* @returns {Promise<Object>} - A promise that resolves to the response data containing the new access token, refresh token, and expiry time.
160
-
* @throws {Error} - Throws an error if no refresh token is available or if the token refresh request fails.
162
+
* @returns {Promise<Object>} A promise that resolves to the response data containing the new access token, refresh token, and expiry time.
163
+
* @throws {Error} Throws an error if no refresh token is available or if the token refresh request fails.
161
164
* @example
162
165
* import * as contentstack from '@contentstack/management'
163
166
* const client = contentstack.client();
@@ -196,8 +199,9 @@ export default class OAuthHandler {
196
199
* @description Logs out the user by revoking the OAuth app authorization
197
200
* @memberof OAuthHandler
198
201
* @func logout
199
-
* @returns {Promise<string>} - A promise that resolves to a success message if the logout was successful.
200
-
* @throws {Error} - Throws an error if the logout request fails.
202
+
* @async
203
+
* @returns {Promise<string>} A promise that resolves to a success message if the logout was successful.
204
+
* @throws {Error} Throws an error if the logout request fails.
201
205
* @example
202
206
* import * as contentstack from '@contentstack/management'
203
207
* const client = contentstack.client();
@@ -219,7 +223,7 @@ export default class OAuthHandler {
219
223
* @description Get the current access token
220
224
* @memberof OAuthHandler
221
225
* @func getAccessToken
222
-
* @returns {any}
226
+
* @returns {string|undefined} Current access token or undefined if not set.
223
227
* @example
224
228
* import * as contentstack from '@contentstack/management'
225
229
* const client = contentstack.client();
@@ -294,7 +298,8 @@ export default class OAuthHandler {
294
298
* @description Set the access token in the axios instance
295
299
* @memberof OAuthHandler
296
300
* @func setAccessToken
297
-
* @param {*} token
301
+
* @param {string} token - Access token to set.
302
+
* @throws {Error} Throws an error if token is not provided.
298
303
* @example
299
304
* import * as contentstack from '@contentstack/management'
300
305
* const client = contentstack.client();
@@ -312,7 +317,8 @@ export default class OAuthHandler {
312
317
* @description Set the refresh token in the axios instance
313
318
* @memberof OAuthHandler
314
319
* @func setRefreshToken
315
-
* @param {*} token
320
+
* @param {string} token - Refresh token to set.
321
+
* @throws {Error} Throws an error if token is not provided.
316
322
* @example
317
323
* import * as contentstack from '@contentstack/management'
318
324
* const client = contentstack.client();
@@ -330,7 +336,8 @@ export default class OAuthHandler {
330
336
* @description Set the organization UID in the axios instance
331
337
* @memberof OAuthHandler
332
338
* @func setOrganizationUID
333
-
* @param {*} organizationUID
339
+
* @param {string} organizationUID - Organization UID to set.
340
+
* @throws {Error} Throws an error if organizationUID is not provided.
334
341
* @example
335
342
* import * as contentstack from '@contentstack/management'
336
343
* const client = contentstack.client();
@@ -348,7 +355,8 @@ export default class OAuthHandler {
348
355
* @description Set the user UID in the axios instance
349
356
* @memberof OAuthHandler
350
357
* @func setUserUID
351
-
* @param {*} userUID
358
+
* @param {string} userUID - User UID to set.
359
+
* @throws {Error} Throws an error if userUID is not provided.
352
360
* @example
353
361
* import * as contentstack from '@contentstack/management'
354
362
* const client = contentstack.client();
@@ -366,7 +374,8 @@ export default class OAuthHandler {
366
374
* @description Set the token expiry time in the axios instance
367
375
* @memberof OAuthHandler
368
376
* @func setTokenExpiryTime
369
-
* @param {*} expiryTime
377
+
* @param {number} expiryTime - Token expiry time (timestamp in milliseconds).
378
+
* @throws {Error} Throws an error if expiryTime is not provided.
370
379
* @example
371
380
* import * as contentstack from '@contentstack/management'
372
381
* const client = contentstack.client();
@@ -386,8 +395,8 @@ export default class OAuthHandler {
386
395
* @func handleRedirect
387
396
* @async
388
397
* @param {string} url - The URL to handle after the OAuth authorization
389
-
* @returns {Promise<void>} - A promise that resolves if the redirect URL is successfully handled
390
-
* @throws {Error} - Throws an error if the authorization code is not found in the redirect URL
398
+
* @returns {Promise<void>} A promise that resolves if the redirect URL is successfully handled
399
+
* @throws {Error} Throws an error if the authorization code is not found in the redirect URL
391
400
* @example
392
401
* import * as contentstack from '@contentstack/management'
393
402
* const client = contentstack.client();
@@ -413,7 +422,8 @@ export default class OAuthHandler {
413
422
* @description Get the OAuth app authorization for the current user
414
423
* @memberof OAuthHandler
415
424
* @func getOauthAppAuthorization
416
-
* @returns {any}
425
+
* @async
426
+
* @returns {Promise<string>} Promise that resolves to authorization UID
417
427
*/
418
428
asyncgetOauthAppAuthorization(){
419
429
constheaders={
@@ -448,8 +458,9 @@ export default class OAuthHandler {
448
458
* @description Revoke the OAuth app authorization for the current user
449
459
* @memberof OAuthHandler
450
460
* @func revokeOauthAppAuthorization
451
-
* @param {any} authorizationId
452
-
* @returns {any}
461
+
* @async
462
+
* @param {string} authorizationId - Authorization ID to revoke
463
+
* @returns {Promise<Object>} Promise that resolves to response data
0 commit comments