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
@@ -4,24 +4,146 @@ A generic OpenID Connect (OIDC) client library for JavaScript and TypeScript, de
4
4
5
5
The oidc module follows the [OIDC](https://openid.net/specs/openid-connect-core-1_0.html) specification and provides a simple and easy-to-use API to interact with the OIDC server. It allows you to authenticate, retrieve the access token, revoke the token, and sign out from the OIDC server.
Initiates the authorization process in the background, returning the authorization code and state or an error. This method handles the authorization flow without requiring user interaction.
12
55
13
-
// Authorize API
14
-
constauthResponse=awaitoidcClient.authorize.background(); // Returns code and state if successful, error if not
15
-
constauthUrl=awaitoidcClient.authorize.url(); // Returns Auth URL or error
constexistingTokens=awaitoidcClient.token.get(); // Returns existing tokens or error
22
-
constresponse=awaitoidcClient.token.revoke(); // Revokes an access token and returns the response or an error
66
+
### token
23
67
24
-
// User API
25
-
constuser=awaitoidcClient.user.info(); // Returns user object or error
26
-
constlogoutResponse=awaitoidcClient.user.logout(); // Logs the user out and returns the response or an error
68
+
Methods for managing OAuth tokens.
69
+
70
+
#### `token.exchange(code, state, options?)`
71
+
72
+
Exchanges an authorization code for tokens using the token endpoint from the wellknown configuration. The tokens are automatically stored in the configured storage.
73
+
74
+
-**Parameters**:
75
+
-`code` (string) - The authorization code received from the authorization server
76
+
-`state` (string) - The state parameter from the authorization URL creation
77
+
-`options` (`Partial<StorageConfig>`, optional) - Storage configuration for persisting tokens
78
+
-**Returns**: `Promise<OauthTokens | TokenExchangeErrorResponse | GenericError>` - The new tokens or an error
0 commit comments