From 9332eb11f62c4188e118bb77abee4208f537f3d7 Mon Sep 17 00:00:00 2001 From: federubinstein Date: Fri, 25 Jul 2025 17:56:28 +0200 Subject: [PATCH 1/6] Updated cody analytics cookie name to SAMS cookie --- docs/analytics/api.mdx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/analytics/api.mdx b/docs/analytics/api.mdx index 54aa3d08b..06fd79a87 100644 --- a/docs/analytics/api.mdx +++ b/docs/analytics/api.mdx @@ -8,17 +8,17 @@ For Sourcegraph Analytics, you can generate an access token for programmatic acc ### Getting Started -Access tokens are created using the `cas` cookie for authentication to the token creation endpoint. Access tokens are longer lived than the `cas` cookie making them more suitable for programmatic access to the Sourcegraph Analytics API. +Access tokens are created using the SAMS session cookie (`accounts_session_v2`) for authentication to the token creation endpoint. Access tokens are longer lived than the SAMS session cookie making them more suitable for programmatic access to the Sourcegraph Analytics API. - Sign in to [Sourcegraph Analytics](https://analytics.sourcegraph.com). -- Retrieve your session cookie, `cas`, from your browser's developer tools. +- Retrieve your SAMS session cookie, `accounts_session_v2`, from your browser's developer tools. ![Sourcegraph Analytics session cookie](https://storage.googleapis.com/sourcegraph-assets/Docs/analytics-cookie.png) - Export the cookie as an environment variable to use in the following commands: ```sh -export CAS_COOKIE="" +export SAMS_COOKIE="" ``` #### Token creation @@ -28,7 +28,7 @@ Create the token by running the following command: ```sh curl -X POST https://analytics.sourcegraph.com/api/service-access-tokens \ -H "Content-Type: application/json" \ - -H "Cookie: cas=$CAS_COOKIE" \ + -H "Cookie: accounts_session_v2=$SAMS_COOKIE" \ -d '{}' # Optionally include displayName, expiresAt, or both in the request body. @@ -54,7 +54,7 @@ List the tokens by running the following command: ```sh curl -X GET https://analytics.sourcegraph.com/api/service-access-tokens \ - -H "Cookie: cas=$CAS_COOKIE" + -H "Cookie: accounts_session_v2=$SAMS_COOKIE" ``` Each token in the response will include the token ID, creation date, a boolean indicating if the token has expired, and display name and expiration date if provided. For example: @@ -98,7 +98,7 @@ Revoke a token by running the following commands: export TOKEN_ID="" curl -X DELETE https://analytics.sourcegraph.com/api/service-access-tokens/$TOKEN_ID \ - -H "Cookie: cas=$CAS_COOKIE" + -H "Cookie: accounts_session_v2=$SAMS_COOKIE" ``` The revocation request does not produce output. To verify that a token has been revoked, list the tokens and verify that `isExpired` is `true`. From c0dd8b6793a8435f8af9b32931b870040660ba34 Mon Sep 17 00:00:00 2001 From: federubinstein Date: Fri, 25 Jul 2025 18:05:33 +0200 Subject: [PATCH 2/6] Update docs/analytics/api.mdx Co-authored-by: Robert Lin --- docs/analytics/api.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/analytics/api.mdx b/docs/analytics/api.mdx index 06fd79a87..379ef0014 100644 --- a/docs/analytics/api.mdx +++ b/docs/analytics/api.mdx @@ -8,7 +8,7 @@ For Sourcegraph Analytics, you can generate an access token for programmatic acc ### Getting Started -Access tokens are created using the SAMS session cookie (`accounts_session_v2`) for authentication to the token creation endpoint. Access tokens are longer lived than the SAMS session cookie making them more suitable for programmatic access to the Sourcegraph Analytics API. +Access tokens are created using the Sourcegraph Accounts (SAMS) session cookie (`accounts_session_v2`) for authentication to the token creation endpoint. Access tokens are longer lived than the SAMS session cookie making them more suitable for programmatic access to the Sourcegraph Analytics API. - Sign in to [Sourcegraph Analytics](https://analytics.sourcegraph.com). - Retrieve your SAMS session cookie, `accounts_session_v2`, from your browser's developer tools. From ac342869f4417cd09006fe5fd31f29f9bfe4bd8f Mon Sep 17 00:00:00 2001 From: federubinstein Date: Fri, 25 Jul 2025 18:26:18 +0200 Subject: [PATCH 3/6] Added name change callout --- docs/analytics/api.mdx | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/analytics/api.mdx b/docs/analytics/api.mdx index 379ef0014..aab9a8dd4 100644 --- a/docs/analytics/api.mdx +++ b/docs/analytics/api.mdx @@ -7,6 +7,7 @@ The Sourcegraph Analytics API is an API that provides programmatic access to you For Sourcegraph Analytics, you can generate an access token for programmatic access. Tokens are long-lived with an optional expiry and have the same permissions to access instance data as the user who created them. ### Getting Started +> **_NOTE:_** As of July 2025, the authentication cookie has changed from `cas` to `accounts_session_v2` (SAMS session cookie). If you have existing scripts using the old cookie name, please update them accordingly. Access tokens are created using the Sourcegraph Accounts (SAMS) session cookie (`accounts_session_v2`) for authentication to the token creation endpoint. Access tokens are longer lived than the SAMS session cookie making them more suitable for programmatic access to the Sourcegraph Analytics API. From b1a37580b516fd0b8b3865085c5dead3921649c7 Mon Sep 17 00:00:00 2001 From: federubinstein Date: Mon, 28 Jul 2025 15:39:29 +0200 Subject: [PATCH 4/6] Changed SAMS mentions to Sourcegraph Accounts --- docs/analytics/api.mdx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/analytics/api.mdx b/docs/analytics/api.mdx index aab9a8dd4..62de918b3 100644 --- a/docs/analytics/api.mdx +++ b/docs/analytics/api.mdx @@ -7,19 +7,19 @@ The Sourcegraph Analytics API is an API that provides programmatic access to you For Sourcegraph Analytics, you can generate an access token for programmatic access. Tokens are long-lived with an optional expiry and have the same permissions to access instance data as the user who created them. ### Getting Started -> **_NOTE:_** As of July 2025, the authentication cookie has changed from `cas` to `accounts_session_v2` (SAMS session cookie). If you have existing scripts using the old cookie name, please update them accordingly. +> **_NOTE:_** As of July 2025, the authentication cookie has changed from `cas` to `accounts_session_v2` (Sourcegraph Accounts session cookie). If you have existing scripts using the old cookie name, please update them accordingly. -Access tokens are created using the Sourcegraph Accounts (SAMS) session cookie (`accounts_session_v2`) for authentication to the token creation endpoint. Access tokens are longer lived than the SAMS session cookie making them more suitable for programmatic access to the Sourcegraph Analytics API. +Access tokens are created using the Sourcegraph Accounts session cookie (`accounts_session_v2`) for authentication to the token creation endpoint. Access tokens are longer lived than the Sourcegraph Accounts session cookie making them more suitable for programmatic access to the Sourcegraph Analytics API. - Sign in to [Sourcegraph Analytics](https://analytics.sourcegraph.com). -- Retrieve your SAMS session cookie, `accounts_session_v2`, from your browser's developer tools. +- Retrieve your Sourcegraph Accounts session cookie, `accounts_session_v2`, from your browser's developer tools. ![Sourcegraph Analytics session cookie](https://storage.googleapis.com/sourcegraph-assets/Docs/analytics-cookie.png) - Export the cookie as an environment variable to use in the following commands: ```sh -export SAMS_COOKIE="" +export ACCOUNTS_COOKIE="" ``` #### Token creation @@ -29,7 +29,7 @@ Create the token by running the following command: ```sh curl -X POST https://analytics.sourcegraph.com/api/service-access-tokens \ -H "Content-Type: application/json" \ - -H "Cookie: accounts_session_v2=$SAMS_COOKIE" \ + -H "Cookie: accounts_session_v2=$ACCOUNTS_COOKIE" \ -d '{}' # Optionally include displayName, expiresAt, or both in the request body. From 946934ce8eec722e699915c7e2252dc2dccab02a Mon Sep 17 00:00:00 2001 From: federubinstein Date: Tue, 29 Jul 2025 12:38:38 +0200 Subject: [PATCH 5/6] Update docs/analytics/api.mdx Co-authored-by: James Cotter <35706755+jac@users.noreply.github.com> --- docs/analytics/api.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/analytics/api.mdx b/docs/analytics/api.mdx index 62de918b3..446a3064d 100644 --- a/docs/analytics/api.mdx +++ b/docs/analytics/api.mdx @@ -55,7 +55,7 @@ List the tokens by running the following command: ```sh curl -X GET https://analytics.sourcegraph.com/api/service-access-tokens \ - -H "Cookie: accounts_session_v2=$SAMS_COOKIE" + -H "Cookie: accounts_session_v2=$ACCOUNTS_COOKIE" ``` Each token in the response will include the token ID, creation date, a boolean indicating if the token has expired, and display name and expiration date if provided. For example: From ddc1d448f99c87832ba3bafac58a0e65663f194a Mon Sep 17 00:00:00 2001 From: federubinstein Date: Tue, 29 Jul 2025 12:38:45 +0200 Subject: [PATCH 6/6] Update docs/analytics/api.mdx Co-authored-by: James Cotter <35706755+jac@users.noreply.github.com> --- docs/analytics/api.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/analytics/api.mdx b/docs/analytics/api.mdx index 446a3064d..8eaa41258 100644 --- a/docs/analytics/api.mdx +++ b/docs/analytics/api.mdx @@ -99,7 +99,7 @@ Revoke a token by running the following commands: export TOKEN_ID="" curl -X DELETE https://analytics.sourcegraph.com/api/service-access-tokens/$TOKEN_ID \ - -H "Cookie: accounts_session_v2=$SAMS_COOKIE" + -H "Cookie: accounts_session_v2=$ACCOUNTS_COOKIE" ``` The revocation request does not produce output. To verify that a token has been revoked, list the tokens and verify that `isExpired` is `true`.