0

这是我正在使用访问 gmail API 通过发送 refresh_token、客户端 ID 和客户端密码来获取 access_token 的 python 程序。我使用的是 Python 2.7 和 OAuth2

def RefreshToken():
    params = {}
    params['client_id'] = '864409438192.apps.googleusercontent.com'
    params['client_secret'] = 'B70rIOnqtyPKI2n4CmgTKPdTES'
    params['refresh_token']= '1/uCLU50d7_iAoKVMKJmnVXhfshrOUOrJDtdun6zK6XiATCKT'
    params['grant_type'] = 'refresh_token'
    request_url = 'https://accounts.google.com/o/oauth2/token'
    response = urllib.urlopen(request_url, urllib.urlencode(params)).read()

执行时出现以下错误

raise IOError, ('http error', errcode, errmsg, headers) IOError: ('http error', 401, 'Unauthorized', )`

我对客户端 ID、客户端密码和刷新令牌有正确的值(在上面的示例中已更改),但仍然不确定我为什么会得到它。有人可以指导我吗

4

0 回答 0