Skip to content

Instantly share code, notes, and snippets.

@tannerlinsley
Created December 4, 2021 00:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tannerlinsley/ffde458359ee79ee9048db7d7a25921f to your computer and use it in GitHub Desktop.
Save tannerlinsley/ffde458359ee79ee9048db7d7a25921f to your computer and use it in GitHub Desktop.
{
"message": [
"Requesting backblaze auth..."
],
"level": "log",
"timestamp": 1638577536200
},
{
"message": [
"btoa error",
"{}"
],
"level": "log",
"timestamp": 1638577536200
},
async function getBackblazeAuth() {
console.log('Requesting backblaze auth...')
let authKeys = ''
try {
authKeys = btoa(
`${process.env.BACKBLAZE_APP_ID}:${process.env.BACKBLAZE_APP_KEY}`,
)
} catch (err) {
console.log('btoa error', JSON.stringify(err))
}
console.log('Accessing backblaze api...')
const { data } = await axios.get<BackblazeAuthResponse>(
`https://api.backblazeb2.com/b2api/v2/b2_authorize_account`,
{ headers: { Authorization: `Basic ${authKeys}` } },
)
return data
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment