Move to bearer token authentication
This tutorial shows how to move your existing integration with Aurora to the new, greatly simplified bearer token-based authentication.
How It Works
With the bearer token authentication, you no longer need your Aurora API key, secret key, or any additional HMAC computation to send a request. All you'll need for authorization is your bearer token.
Getting Started
To complete this recipe:
- Your Aurora tenant needs to be on the Custom plan.
- You need a bearer token that any Administrator for your Aurora tenant can retrieve from the API Settings page.
Step 1. Remove HMAC setup from your code.
You can now safely remove the following HMAC setup pieces from your code:
host = "api-sandbox.aurorasolar.com"
api_uri = "/v2/tenants/your-tenants-UUID-123"
aurora_api_key = "ABCDEFGHIJKLMEXAMPLE"
aurora_api_secret = "AuroraSolarAPISecret"
timestamp = URI.escape(Time.now.utc.to_s)
http_verb = "GET"
formated_request_string = HMacHelper.format_request_string(http_verb, api_uri, aurora_api_key, timestamp)
signature = HMacHelper.compute_hmac_signature(formated_request_string, aurora_api_secret)
uri_encoded_signature = URI.escape(signature)
end_point = "https://#{host}#{api_uri}?AuroraKey=#{aurora_api_key}&Timestamp=#{timestamp}&Signature=#{uri_encoded_signature}"
uri = URI(end_point)
request = Net::HTTP::Get.new(uri)
response = http.request(request)
Step 2. Replace your HMAC signature with a bearer token call.
Bearer token call uses your bearer token as an authentication header:
host = "api-sandbox.aurorasolar.com"
api_uri = "/v2/tenants/your-tenants-UUID-123"
bearer_token = "sk_sand_your-bearer-token"
uri = URI("https://#{host}#{api_uri}")
request = Net::HTTP::Get.new(uri)
request["Authentication"] = "Bearer #{bearer_token}"
response = http.request(request)
Limitations
If you’re still using the legacy Aurora, please contact your Aurora account team to request a bearer token.
Updated over 2 years ago