In this section, we’ll look at passing Authorization and Authentication information in our requests, by accessing the GitHub REST API. Let’s try making aDocumentation Index
Fetch the complete documentation index at: https://docs.hoppscotch.io/llms.txt
Use this file to discover all available pages before exploring further.
GET request to the URL https://api.github.com/user.
You’ll get the following response:
Generating access token
To get access to the GitHub API, you first need to generate a personal access token. For our demonstration, we will generate one granting access to public repositories.- Login to the GitHub account.
- Go to your personal access tokens page and click on “Generate new token”.
- Select tokens (classic).
- Specify the note as “Hoppscotch API” so that you can remember why you created it.
- Under the “Select scopes” section only check
public_repo. - Scroll down and click on “Generate token”.
- You just generated your access token, now copy the token to your clipboard.
Storing auth token in a variable
- Click on the “Global” environment to add a variable.
- Create a variable called
tokenand paste the token from GitHub as its value. - Now open the Authorization tab and select
Bearerfrom the dropdown list. - Input the token as shown below, make sure that you reference the token in variable format, i.e.
<<token>>. - Click on “Send”.