Creating an access token
Access tokens permit authenticated access to the Sourcegraph API. This is required for the src
command line interface to Sourcegraph to operate, and also allows other tools that integrate with Sourcegraph to issue requests on your behalf.
Creating an access token is done through your user settings. This video shows the steps, which are then described below:
-
From any Sourcegraph page, click on your avatar at the top right of the page.
-
Select Settings from the dropdown menu.
-
Select Access tokens from the sidebar menu.
-
Click Generate new token.
-
Enter a description, such as
src
.NOTE: The
user:all
scope that is selected by default is sufficient for all normalsrc
usage, and most uses of the GraphQL API. If you're an admin, you should only enablesite-admin:sudo
if you intend to impersonate other users. -
Select how long the access token should remain valid.
-
Click Generate token.
-
Sourcegraph will now display your access token. You must copy it from this screen: once this page is closed, you cannot access the token again and can only revoke it and issue a new one.
You can then set the SRC_ACCESS_TOKEN
environment variable to the token to use it with src
.