- Using Personal Access Tokens for API Authentication
- FAQs
- External Applications (OAuth)
- API Keys
- ROPC (not recommended)
Using Personal Access Tokens for API Authentication
Personal Access Tokens (PATs) are a secure way to authenticate and authorize API requests. This section will guide you through the process of including tokens in your API requests, and provide guidance on handling authentication errors.
Including tokens in API requests
Authorization header
The most common method is to include the token in the Authorization header of your HTTPS request. Use the Bearer scheme followed by a space and the token value. For example:Authorization: Bearer {token}
Authorization: Bearer {token}
Handling token authentication errors
The most common error while using Personal Access Tokens is 401 Unauthorized. The 401 Unauthorized error might arise if the provided PAT is missing, expired, or lacks the necessary permissions. The error intentionally omits specific information to prevent the exposure of sensitive data.
How to handle the error
-
Ensure that you've correctly included the token in your request.
-
Verify that the token has the appropriate scopes for the action you're attempting.
-
Renew or regenerate the token if it has expired.