File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed
Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -46,13 +46,22 @@ import { WorkOS } from '@workos-inc/node';
4646
4747const workos = new WorkOS ({ clientId: ' client_...' }); // No API key needed
4848
49- // These methods work without an API key:
50- // - workos.userManagement.getAuthorizationUrl() with PKCE
51- // - workos.userManagement.authenticateWithCodeAndVerifier()
52- // - workos.userManagement.authenticateWithRefreshToken()
49+ // Generate auth URL with automatic PKCE
50+ const { url, codeVerifier } = await workos .userManagement .getAuthorizationUrlWithPKCE ({
51+ provider: ' authkit' ,
52+ redirectUri: ' myapp://callback' ,
53+ clientId: ' client_...' ,
54+ });
55+
56+ // After user authenticates, exchange code for tokens
57+ const { accessToken, refreshToken } = await workos .userManagement .authenticateWithCode ({
58+ code: authorizationCode ,
59+ codeVerifier ,
60+ clientId: ' client_...' ,
61+ });
5362```
5463
55- Use PKCE (Proof Key for Code Exchange) for secure auth code exchange. See the [ AuthKit documentation] ( https://workos.com/docs/authkit ) for details.
64+ See the [ AuthKit documentation] ( https://workos.com/docs/authkit ) for details on PKCE authentication .
5665
5766## SDK Versioning
5867
You can’t perform that action at this time.
0 commit comments