When performing certain API requests you must send an authentication header with your request. This allows us to verify you and prevent unauthorized parties making changes to the content on your apps.
To send unsigned requests, include your public key in the "Authorization" header of the request, preceded by the word "public":
Authorization: public MY_PUBLIC_KEYReading files, images and videos needs no authorization unless the app requires signed URLs.
Unsigned requests are appropriate for client-side operations, but may have reduced permissions depending on your app settings.
Generating an authentication token is a four step process:
publicKey$token$encryptedTokenAuthorization: token MY_AUTH_STRINGAn example implementation could be:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15function generateAuthorizationHeader(publicKey, privateKey) { const token = random.string(32) const encryptedToken = JWT.sign(token, privateKey) return "token " + [publicKey, token, encryptedToken].join("$") } // make an API request to fileboy sending the authentication header httpRequest( "https://api.fileboy.io/files/delete/1234-1234-1234", { headers: { Authorization: generateAuthorizationHeader(YOUR_PUBLIC_KEY, YOUR_PRIVATE_KEY) } } )
In addition to generating your own tokens as described above, you may also want to make use of authentication tokens obtained from one of our libraries or an API response.
You can use a valid authentication token to authorize a request by including it in the "Authorization" header in the same way:
Authorization: token MY_PREMADE_TOKEN