Python -401尝试从GMAIL API的刷新令牌获取access_token时发生未经授权的错误

时间:2015-08-27 19:35:12

标签: python api oauth gmail-api incoming-mail

这是我正在使用访问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()

执行时我收到以下错误

  

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

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

0 个答案:

没有答案
相关问题