auth_web.py 文件源码

python
阅读 36 收藏 0 点赞 0 评论 0

项目:AlexaPi 作者: alexa-pi 项目源码 文件源码
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>"
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号