Account Re-authentication
By using an account's sync_state
, you can determine when the user should re-authenticate their account. A user may need to re-authenticate for a number of reasons. For example, it could be that their password changed, or that Nylas' access was revoked by the server.
Aside from the sync status info provided in the Nylas dashboard, you can determine an account's sync_state
using the API.
Current Sync State
There are three ways to find a Nylas account's current sync_state
using the API.
Account Endpoint Poll Requests
Make poll requests to the /account endpoint and check the sync_state
. If it's invalid
, the user needs to re-authenticate. The user also needs to re-authenticate if you receive a 401
response.
Account Management Endpoint Poll Requests
Make poll requests to the Account management endpoints and check the sync_state
. The user needs to re-authenticate if the value is invalid-credentials.
Webhooks
Subscribe to Webhooks with the account.*
triggers to stay up to date with account status changes. If you receive account.invalid
, the user needs to re-authenticate.
Best Practices
We recommend building out support for Webhooks and either Account or Account management endpoint poll requests within your system to stay up to date around account sync_state
updates.