Created
May 25, 2021 15:46
-
-
Save leemartin/4adcfe4032ab5a118489066e8b647599 to your computer and use it in GitHub Desktop.
IBM Watson Token Requester
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
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