Skip to content

Instantly share code, notes, and snippets.

@leemartin
Created May 25, 2021 15:46
Show Gist options
  • Save leemartin/4adcfe4032ab5a118489066e8b647599 to your computer and use it in GitHub Desktop.
Save leemartin/4adcfe4032ab5a118489066e8b647599 to your computer and use it in GitHub Desktop.
IBM Watson Token Requester
const { IamTokenManager } = require('ibm-watson/auth')
const sttAuthenticator = new IamTokenManager({
apikey: process.env.SPEECH_TO_TEXT_IAM_APIKEY
})
const handler = async (event) => {
try {
let { result } = await sttAuthenticator.requestToken()
return {
statusCode: 200,
body: JSON.stringify({
accessToken: result.access_token
})
}
} catch (error) {
console.log(error)
return {
statusCode: 500,
body: error.toString()
}
}
}
module.exports = { handler }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment