6 Log into the BSR
You've gone over many of the primary buf
commands, so now you'll shift gears
and learn how to use buf
to interact with the Buf Schema Registry (BSR) to
manage our PetStoreService
API.
#
6.1 Log inVisit https://buf.build/login and you'll be prompted with a few different login options, including Google, GitHub, and traditional email and password. After you've successfully authenticated, you'll be prompted to select a username and complete your registration. If successful, you should see that you're logged in and that your username is rendered in the upper right-hand corner.
Throughout this tour, you'll see references to the BUF_USER
environment
variable as your newly created BSR username. Once you have completed
registration, export this value so that you can copy and paste commands.
# Note this is just for the tour!$ export BUF_USER=<YOUR_BUF_USER>
Any time the
$BUF_USER
placeholder is used within a file, such asbuf.yaml
, you need to manually replace it with your local value ofBUF_USER
.
#
6.2 Create an API TokenNow that you're logged in, visit the https://buf.build/settings/user
page and click the Create New Token button. Select an expiration time and
add a note for yourself to distinguish this token from others (we recommend that
you name this CLI
, Development
, or something else along those lines).
Click Create and copy the token to your clipboard.
buf registry login
#
6.3 All you need to log in is the API token created above. Run this command to do so:
$ buf registry login
You'll be prompted for your username and the token that you just copied.
In the future, the buf
CLI will get its authentication credentials from your
$HOME/.netrc
file. The buf registry login
command automatically writes your
supplied creds to that file, which should now look like this:
machine buf.build login <USERNAME> password <TOKEN>machine go.buf.build login <USERNAME> password <TOKEN>
You can log out at any time using this command:
$ buf registry logout
OutputAll existing BSR credentials removed from $HOME/.netrc.
For more information on .netrc
, check out the
curl documentation.
If you're developing on a Windows machine, the credentials file is
%HOME%/_netrc
.