def code(self, var=None, **params): # pylint: disable=unused-argument
code = quote(cherrypy.request.params['code'])
callback = cherrypy.url()
payload = {
"client_id": config['alexa']['Client_ID'],
"client_secret": config['alexa']['Client_Secret'],
"code": code,
"grant_type": "authorization_code",
"redirect_uri": callback
}
url = "https://api.amazon.com/auth/o2/token"
response = requests.post(url, data=payload)
resp = response.json()
alexapi.config.set_variable(['alexa', 'refresh_token'], resp['refresh_token'])
return "<h2>Success!</h2>" \
"<p>The refresh token has been added to your config file.</p>" \
"<p>Now:</p>" \
"<ul>" \
"<li>close your this browser window,</li>" \
"<li>exit the setup script as indicated,</li>" \
"<li>and follow the Post-installation steps.</li>" \
"</ul>"
评论列表
文章目录