Learn various authorization methods you need to use Gluwa API.
Gluwa has two types of authorizing a request:
X-REQUEST-SIGNATURE header
Authorization header
Depending on the request, you may have to use at least one of them or none at all. Look under Request -> Headers section under each endpoint to find out if an endpoint requires authorization.
X-REQUEST-SIGNATURE
X-REQUEST-SIGNATURE header is used to verify the ownership of an address, usually, for GET requests. The value of the header must be the signature of an address that you own. Follow the guide below to generate an Address Signature.
Then, you can generate the value of the header like below:
// example key and secretvar key ='abcd';var secret ='1234';var data = key +':'+ secret;var encodedBytes =Buffer.from(data);// this is Base64 Encoded API Keysvar encodedString =encodedBytes.toString('base64');// you should get 'YWJjZDoxMjM0' from the example valuesconsole.log(encodedString)
import base64# example key and secretkey ='abcd'secret ='1234'data ='%s:%s'% (key, secret)encodedBytes = base64.b64encode(data.encode('utf-8'))# this is Base64 Encoded API KeysencodedString = encodedBytes.decode('utf-8')# you should get 'YWJjZDoxMjM0' from the example valuesprint(encodedString)
usingSystem;usingSystem.Text;...string apiKey ="abcd";string apiSecret ="1234";// token's value is YWJjZDoxMjM0string token =Convert.ToBase64String(Encoding.UTF8.GetBytes($"{apiKey}:{apiSecret}"));