Is there any way I can use an API to generate LWA Tokens for ALEXA Skill Management API authorization?
Right now, I am generating LWA tokens through ASK-CLI and copying-pasting into the ASK-SMAPI-SDK code. Is there any API/way to automate this process?
Any help is greatly appreciated.
There are multiple ways to interpret your question..
One is you want various customers/accounts to be able to login and generate a token with the web interface instead of you having to manually generate it through the CLI.
If so, there are a number of OAuth libraries that support LWA. Last one I messed with was Passport (for Node), but that was a while ago. Just make sure you're requesting the right scopes because most of the libraries default to the the profile scope.
Another is that you're generating tokens every time you want to run your script because they expire.
In that case, the
ask util generate-lwa-tokenscommand returns an access token and a refresh token. The access token is good for an hour. The refresh token is good indefinitely, but needs to be traded for a new access token when the last one runs out (usually 3600 seconds after issue).Consider using the ASK SMAPI SDK.
https://developer.amazon.com/en-US/blogs/alexa/alexa-skills-kit/2020/05/three-tips-for-coding-with-the-alexa-smapi-sdk
In the SDK, you feed the SDK client your access token and refresh token. If the access token is dust, it will get you a new one with the refresh token and use that. The SDK does some of the heavy lifting for you, so you might want to consider it.
But maybe you've written your own scripts and don't want to convert them. Here are the LWA docs on using your refresh token in case you want to write your own client. IT's a REST API, so you just have to be able to generate the HTTP request.
https://developer.amazon.com/docs/login-with-amazon/retrieve-token-other-platforms-cbl-docs.html#using-refresh-tokens
Workflow is like this...