auth_web.py 文件源码

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

项目:Alexa 作者: respeaker 项目源码 文件源码
def authresponse(self, var=None, **params):
        code = urllib.quote(cherrypy.request.params['code'])
        callback = cherrypy.url()
        payload = {"client_id": Client_ID, "client_secret": Client_Secret, "code": code,
                   "grant_type": "authorization_code", "redirect_uri": callback}
        url = "https://api.amazon.com/auth/o2/token"
        r = requests.post(url, data=payload)
        resp = r.json()
        line = '\nrefresh_token = "{}"'.format(resp['refresh_token'])
        with open("creds.py", 'a') as f:
            f.write(line)
        return "Success!, refresh token has been added to your creds file, you may now run <code>python alexa.py</code> <br>{}".format(
            resp['refresh_token'])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号