Authentication
For app's server to request any data from the Fyre server using APIs, it needs to authentication itself to Fyre backend.
Authentication happens on every single request by sending a digital signature in the request body. The Fyre server verifies the signature before sending data.
In order to generate a signature, the app's server need to sign message (message
feld of the request body) using registered app's private key and send the signature in fyresign
field of the request body.
Sample code snippet to generate signature in Javascript:
In the above code, we used standard web3
package to generate digital signature. There are libraries available in various different languages like JavaScript, Go etc which can used based on requirement.
To sign a message, all you have to do is, use web3.eth.sign()
function. The funcation takes two parameters:
a
message
: Will contain the request parameters, depending on the need.a
privateKey
: Generated during the app registration phase.
web3.eth.sign()
returns three values message
, signature
and messageHash
.
The server need to send all these parameters in the request body of any API call to Fyre backend.
Note:
Make sure to send the
signature
in thefyresign
field in the request body.We only accept message in specific format. Read the API documentation to understand the message format.
We learnt how an app's server can produce a digital signature in order to authenticate itself to Fyre server and request data, in the next section we will see what all APIs available and how to call them.
Last updated