ReshScore's API key authentication is the simplest way to authenticate API requests. After generating an API key from your dashboard, you can include it in the HTTP headers of your request to access the API endpoints.
Steps to authenticate with an API key:
Authorization: Bearer YOUR_API_KEY
Example of a curl request using the API key:
curl -X GET 'https://api.reshscore.com/v1/credit-score/{userId}' \
-H 'Authorization: Bearer YOUR_API_KEY'
Important: Keep your API key private. Do not expose it in public repositories or share it with others. If your API key is compromised, regenerate it immediately in your dashboard.
For more secure and scalable authentication, ReshScore supports OAuth2, a widely used authentication framework that allows secure authorization for accessing resources without sharing credentials.
Steps to authenticate using OAuth2:
Example request:
curl -X POST 'https://api.reshscore.com/oauth/token' \
-d 'client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET&grant_type=client_credentials'
Authorization: Bearer ACCESS_TOKEN
Example of a curl request with OAuth2:
curl -X GET 'https://api.reshscore.com/v1/credit-score/{userId}' \
-H 'Authorization: Bearer YOUR_ACCESS_TOKEN'
Note: Access tokens are temporary and must be refreshed when they expire.
Access tokens obtained via OAuth2 have a limited lifespan for security reasons. When a token expires, you must refresh it to continue accessing the API.
How to know when a token expires:
expires_in
field, which specifies the number of seconds the token is valid.Steps to refresh a token:
Example request:
curl -X POST 'https://api.reshscore.com/oauth/token' \
-d 'client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET&grant_type=refresh_token&refresh_token=YOUR_REFRESH_TOKEN'
Best Practices:
Authentication errors can occur for several reasons, such as expired tokens, invalid API keys, or missing credentials. Here’s how to handle common authentication errors.
1. 401 Unauthorized:
2. 403 Forbidden:
3. 400 Bad Request:
4. 500 Internal Server Error:
Best Practices for Error Handling: