> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zylon.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenID & OAuth

> Start SSO logins and integration OAuth flows for Confluence and SharePoint.

Use these endpoints to initiate OAuth/OpenID flows. Login endpoints are browser-oriented and return redirects; callback endpoints receive the provider response.

> Integrations must be enabled before you use their OAuth endpoints. See the operator guides for [Confluence](/en/operator-manual/knowledge-base/confluence) and [SharePoint](/en/operator-manual/knowledge-base/sharepoint).

## Basic request and response

Start a login flow by calling a provider login endpoint and following the redirect.

### User SSO login redirects

<Tabs>
  <Tab title="Google login">
    ```bash theme={null}
    curl -i "https://{BASE_URL}/api/v1/auth/google/login"
    ```

    <Accordion title="Example response">
      ```text theme={null}
      HTTP/1.1 302 Found
      Location: https://accounts.google.com/o/oauth2/v2/auth?client_id=...&redirect_uri=...
      ```
    </Accordion>
  </Tab>

  <Tab title="Microsoft login">
    ```bash theme={null}
    curl -i "https://{BASE_URL}/api/v1/auth/microsoft/login"
    ```

    <Accordion title="Example response">
      ```text theme={null}
      HTTP/1.1 302 Found
      Location: https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=...&redirect_uri=...
      ```
    </Accordion>
  </Tab>
</Tabs>

### Integration OAuth login redirects

<Tabs>
  <Tab title="Confluence login">
    ```bash theme={null}
    curl -i "https://{BASE_URL}/api/v1/app/integration/confluence/login"
    ```

    <Accordion title="Example response">
      ```text theme={null}
      HTTP/1.1 302 Found
      Location: https://auth.atlassian.com/authorize?client_id=...&redirect_uri=...
      ```
    </Accordion>
  </Tab>

  <Tab title="SharePoint login">
    ```bash theme={null}
    curl -i "https://{BASE_URL}/api/v1/app/integration/sharepoint/login"
    ```

    <Accordion title="Example response">
      ```text theme={null}
      HTTP/1.1 302 Found
      Location: https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=...&redirect_uri=...
      ```
    </Accordion>
  </Tab>
</Tabs>

### Login with a specific integration instance

<Tabs>
  <Tab title="Confluence instance">
    ```bash theme={null}
    curl -i "https://{BASE_URL}/api/v1/app/integration/confluence/{integrationID}/login"
    ```

    <Accordion title="Example response">
      ```text theme={null}
      HTTP/1.1 302 Found
      Location: https://auth.atlassian.com/authorize?client_id=...&state=conf_8a7b6c5d4e3f2a1b
      ```
    </Accordion>
  </Tab>

  <Tab title="SharePoint instance">
    ```bash theme={null}
    curl -i "https://{BASE_URL}/api/v1/app/integration/sharepoint/{integrationID}/login"
    ```

    <Accordion title="Example response">
      ```text theme={null}
      HTTP/1.1 302 Found
      Location: https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=...&state=sp_1c2d3e4f5a6b7c8d
      ```
    </Accordion>
  </Tab>
</Tabs>

### Refresh an integration token

<Tabs>
  <Tab title="Confluence refresh">
    ```bash theme={null}
    curl -X POST "https://{BASE_URL}/api/v1/app/integration/confluence/{integrationID}/refresh_token" \
      -H "Authorization: Bearer {API_TOKEN}"
    ```

    <Accordion title="Example response">
      ```json theme={null}
      "ok"
      ```
    </Accordion>
  </Tab>

  <Tab title="SharePoint refresh">
    ```bash theme={null}
    curl -X POST "https://{BASE_URL}/api/v1/app/integration/sharepoint/{integrationID}/refresh_token" \
      -H "Authorization: Bearer {API_TOKEN}"
    ```

    <Accordion title="Example response">
      ```json theme={null}
      "ok"
      ```
    </Accordion>
  </Tab>
</Tabs>

### Callback endpoints

<Tabs>
  <Tab title="Microsoft callback">
    ```bash theme={null}
    curl -i "https://{BASE_URL}/api/v1/auth/microsoft/callback?code=...&state=..."
    ```

    <Accordion title="Example response">
      ```text theme={null}
      HTTP/1.1 302 Found
      Location: https://{BASE_URL}/app/login/success
      ```
    </Accordion>
  </Tab>

  <Tab title="Confluence callback">
    ```bash theme={null}
    curl -i "https://{BASE_URL}/api/v1/app/integration/confluence/callback?code=...&state=..."
    ```

    <Accordion title="Example response">
      ```text theme={null}
      HTTP/1.1 302 Found
      Location: https://{BASE_URL}/app/integrations/confluence
      ```
    </Accordion>
  </Tab>

  <Tab title="SharePoint callback">
    ```bash theme={null}
    curl -i "https://{BASE_URL}/api/v1/app/integration/sharepoint/callback?code=...&state=..."
    ```

    <Accordion title="Example response">
      ```text theme={null}
      HTTP/1.1 302 Found
      Location: https://{BASE_URL}/app/integrations/sharepoint
      ```
    </Accordion>
  </Tab>
</Tabs>

## Errors and edge cases

* **302 redirect**: expected for login and callback routes.
* **401/403**: token missing for refresh.
* **404**: integration ID not found.
