【发布时间】:2017-11-14 21:11:21
【问题描述】:
我正在存储 oauth2 凭据,以便以后创建服务。
目前我的模型如下所示:
from django.db import models
from oauth2client.contrib.django_util.models import CredentialsField
from south.modelsinspector import add_introspection_rules
class oAuth(models.Model):
siteid = models.CharField(max_length=100L, primary_key=True)
credential = CredentialsField()
add_introspection_rules([],["^oauth2client\.contrib\.django_util\.models\.CredentialsField"])
当我尝试保存我的凭据时:
credential = flow.step2_exchange(code)
storage = DjangoORMStorage(oAuth, 'siteid', site_id, 'credential')
storage.put(credential)
在我的数据库中,我存储了一个 unicode 字符串,然后无法使用以下方法将其转换为 oauth 对象:
storage = DjangoORMStorage(oAuth, 'siteid', site_id, 'credential')
credential = storage.get()
return credential
我得到的凭据是以前存储的 unicode,我只是无法对其执行 .authorize 方法,这是我需要做的,
我是不是在什么地方弄糊涂了?
【问题讨论】:
标签: python django oauth double-click