-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add code to retrieve sxt access token (#27)
- Loading branch information
Showing
3 changed files
with
22 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,24 @@ | ||
|
||
// Ensure the API key is available | ||
if (!secrets.apiKey) { | ||
throw Error("API Key Not Found"); | ||
} | ||
|
||
// NOTE: Do NOT use this apiKey here in production, it is only here to demonstrate secrets. | ||
return Functions.encodeString(secrets.apiKey); | ||
// Construct a payload to fetch an accesstoken to be used for | ||
// api access to the prover. It is a required component of the payload to | ||
// receive a proof. | ||
// Set the secrets field to an apiKey that you own for your sxt account. | ||
|
||
// Execute the API request using Functions.makeHttpRequest | ||
const apiResponse = await Functions.makeHttpRequest({ | ||
url: "https://proxy.api.spaceandtime.dev/auth/apikey", | ||
method: "POST", | ||
headers: { | ||
"apikey": secrets.apiKey, | ||
"Content-Type": "application/json" | ||
} | ||
}); | ||
|
||
// Extract the access token, truncate it to 256 characters, and return it as an encoded string | ||
const accessToken = apiResponse.data.accessToken; | ||
return Functions.encodeString("TODO"); |