Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ms-access/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用来自django social auth的OAuth访问令牌和Google数据api(日历)_Django_Oauth_Gdata_Google Data Api_Django Socialauth - Fatal编程技术网

使用来自django social auth的OAuth访问令牌和Google数据api(日历)

使用来自django social auth的OAuth访问令牌和Google数据api(日历),django,oauth,gdata,google-data-api,django-socialauth,Django,Oauth,Gdata,Google Data Api,Django Socialauth,我试图使用从django social auth获得的OAuth令牌访问用户日历 因此,在django social auth配置中,我设置: GOOGLE_CONSUMER_KEY = 'anonymous' GOOGLE_CONSUMER_SECRET = 'anonymous' GOOGLE_OAUTH_EXTRA_SCOPE = ['https://www.google.com/calendar/feeds/'] 当用户从google返回时,我在数据库中得到一个条目,如下所示: {u'

我试图使用从django social auth获得的OAuth令牌访问用户日历

因此,在django social auth配置中,我设置:

GOOGLE_CONSUMER_KEY = 'anonymous'
GOOGLE_CONSUMER_SECRET = 'anonymous'
GOOGLE_OAUTH_EXTRA_SCOPE = ['https://www.google.com/calendar/feeds/']
当用户从google返回时,我在数据库中得到一个条目,如下所示:

{u'access_token': u'oauth_token_secret=vvvv&oauth_token=xxxx'}
import gdata.calendar.client

client = gdata.calendar.client.CalendarClient()
client.auth_token = gdata.gauth.OAuthHmacToken('anonymous', 'anonymous', 'xxxx', 'vvvv', gdata.gauth.ACCESS_TOKEN)

client.GetOwnCalendarsFeed()
但是现在,当我尝试做这样的事情时:

{u'access_token': u'oauth_token_secret=vvvv&oauth_token=xxxx'}
import gdata.calendar.client

client = gdata.calendar.client.CalendarClient()
client.auth_token = gdata.gauth.OAuthHmacToken('anonymous', 'anonymous', 'xxxx', 'vvvv', gdata.gauth.ACCESS_TOKEN)

client.GetOwnCalendarsFeed()
我总是得到:

gdata.client.Unauthorized: Unauthorized - Server responded with: 401
<HEAD>
<TITLE>Token invalid - Invalid AuthSub token.</TITLE>
</HEAD>
gdata.client.Unauthorized:Unauthorized-服务器响应为:401
令牌无效-无效的AuthSub令牌。

我在这里错过了什么?

哈利路亚!Django social auth返回带有转义正斜杠(%2F)的访问令牌。用“/”替换它对我来说很有用

HTH

这对我来说很有用:

from social_auth.models import UserSocialAuth

def do_something_with_tokens(request):
  tokens = UserSocialAuth.get_social_auth_for_user(request.user).get().tokens
  ...

您使用的是OAuth还是OAuth2?我有完全相同的问题。快把我逼疯了。我正在使用OAuth,并尝试使用匿名密钥和注册密钥。