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
Copy file name to clipboardExpand all lines: packages/nylas-connect/README.md
+52Lines changed: 52 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -284,6 +284,58 @@ Match your Nylas account region:
284
284
285
285
Automatic. @nylas/connect handles token refresh in the background.
286
286
287
+
288
+
# External Identity Provider Integration Example
289
+
290
+
This example demonstrates how to use the new `identityProviderToken` callback feature to integrate external identity providers (via JWKS) with Nylas Connect.
291
+
292
+
## Basic Usage
293
+
294
+
```typescript
295
+
import { NylasConnect } from'@nylas/connect';
296
+
297
+
// Example: Using a function that returns a JWT token
returntoken; // Return the JWT string, or null if not available
308
+
}
309
+
});
310
+
311
+
// The rest works the same as before
312
+
const result =awaitconnect.connect({ method: 'popup' });
313
+
```
314
+
315
+
316
+
## How It Works
317
+
318
+
1. When you call `connect.connect()`, the authentication flow proceeds normally
319
+
2. During the token exchange step (when exchanging the authorization code for access tokens), the `identityProviderToken` callback is called
320
+
3. If the callback returns a JWT token, it's sent to Nylas as the `idp_claims` parameter
321
+
4. If the callback returns `null` or throws an error:
322
+
- Returning `null`: The auth flow continues without IDP claims
323
+
- Throwing an error: The entire token exchange fails with a `NETWORK_ERROR` event
324
+
325
+
## Error Handling
326
+
327
+
If the `identityProviderToken` callback throws an error, the entire authentication flow will fail with a `NETWORK_ERROR` event. You can listen for this event to handle IDP-related errors:
0 commit comments