如何使用Tube API中的刷新令牌更新访问令牌? [英] How to update access token using refresh token in you tube api?

查看:116
本文介绍了如何使用Tube API中的刷新令牌更新访问令牌?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经尝试过以此来更新我的访问令牌

I have tried this to update my access token

import urllib
endpoint='https://accounts.google.com/o/oauth2/token'
data={'client_id':'25********15-6*********************7f.apps.googleusercontent.com','client_secret':'4********Pj-K*****x4aM','refresh_token':'1/tP************************O_XclU','grant_type':'refresh_token'}
encodedData=urllib.urlencode(data)
from httplib2 import Http
h = Http()
resp, content = h.request(endpoint, "POST", encodedData)

但是收到错误消息

'{\n  "error" : "invalid_request",\n  "error_description" : "Required parameter is missing: grant_type"\n}'

推荐答案

您应像这样在请求中指定标头:

You should specify the headers in your request like this:

resp, content = h.request(uri=endpoint,
                          method="POST", 
                          body=encodedData, 
                          headers={'Content-type': 'application/x-www-form-urlencoded'})

这篇关于如何使用Tube API中的刷新令牌更新访问令牌?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆