In Cobalt, re-authentication of a user for an integration is typically managed automatically.

In certain scenarios where automatic re-authentication is not feasible, users may need to manually handle re-authentication. This process becomes necessary when either the refresh tokens expire, OAuth apps are deleted, integrations are disconnected, or access tokens are manually expired by the user. To facilitate this, you can identify the need for re-authentication and guide your users through the reconnection process effectively.

Determining the Need for Re-Authentication

To determine if re-authentication is required, you can either use the List Applications API or .getApp() SDK method and check the reauth_required field in the response. By default, the field is false but if it returns true, then it indicates that re-authentication is necessary.

Response
[
    {
        "name": "Drive",
        "icon": "https://cobalt-app-logos.s3.ap-south-1.amazonaws.com/google_drive/logo.png",
        "description": "Google Drive is Google's file sync app that lets you store all of your files online alongside your Google Docs documents, and keep them synced with all of your devices.",
        "auth_type": "oauth2",
        "tags": [
            "Office"
        ],
        "version": {
            "_v": "1.0.0",
            "description": "Google Drive is Google's file sync app that lets you store all of your files online alongside your Google Docs documents, and keep them synced with all of your devices."
        },
        "slug": "google_drive",
        "reauth_required": false // Re-Auth is not required.
    },
    {
        "name": "Copper",
        "icon": "https://cobalt-app-logos.s3.ap-south-1.amazonaws.com/copper/logo.png",
        "description": "Copper is a customer relationship management (CRM) platform focused on automation and simplicity. It is built for businesses that use Google Workspace.",
        "auth_type": "keybased",
        "tags": [
            "CRM"
        ],
        "auth_input_map": [
            {
                "name": "api_token",
                "label": "API Key",
                "placeholder": "Please enter the API key",
                "required": true,
                "type": "text"
            },
            {
                "name": "email",
                "label": "Email Address",
                "placeholder": "Please enter the email of the token owner",
                "required": true,
                "type": "text"
            }
        ],
        "version": {
            "_v": "1.0.0",
            "description": "Copper is a customer relationship management (CRM) platform focused on automation and simplicity. It is built for businesses that use Google Workspace."
        },
        "slug": "copper",
        "reauth_required": true // Re-Auth is required.
    }
]

Manual Re-Authentication Process

If the reauth_required field is true, then you need to get the user re-authenticated with the application.

React SDK: If you are using the Cobalt React SDK, Cobalt provides a pre-built Reconnect button for seamless reconnection.