当前位置: 首页>>代码示例>>Python>>正文


Python storage.DjangoORMStorage方法代码示例

本文整理汇总了Python中oauth2client.contrib.django_util.storage.DjangoORMStorage方法的典型用法代码示例。如果您正苦于以下问题:Python storage.DjangoORMStorage方法的具体用法?Python storage.DjangoORMStorage怎么用?Python storage.DjangoORMStorage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在oauth2client.contrib.django_util.storage的用法示例。


在下文中一共展示了storage.DjangoORMStorage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_storage

# 需要导入模块: from oauth2client.contrib.django_util import storage [as 别名]
# 或者: from oauth2client.contrib.django_util.storage import DjangoORMStorage [as 别名]
def get_storage(request):
    """ Gets a Credentials storage object provided by the Django OAuth2 Helper
    object.

    Args:
        request: Reference to the current request object.

    Returns:
       An :class:`oauth2.client.Storage` object.
    """
    storage_model = oauth2_settings.storage_model
    user_property = oauth2_settings.storage_model_user_property
    credentials_property = oauth2_settings.storage_model_credentials_property

    if storage_model:
        module_name, class_name = storage_model.rsplit('.', 1)
        module = importlib.import_module(module_name)
        storage_model_class = getattr(module, class_name)
        return storage.DjangoORMStorage(storage_model_class,
                                        user_property,
                                        request.user,
                                        credentials_property)
    else:
        # use session
        return dictionary_storage.DictionaryStorage(
            request.session, key=_CREDENTIALS_KEY) 
开发者ID:taers232c,项目名称:GAMADV-XTD,代码行数:28,代码来源:__init__.py

示例2: maybe_authorize

# 需要导入模块: from oauth2client.contrib.django_util import storage [as 别名]
# 或者: from oauth2client.contrib.django_util.storage import DjangoORMStorage [as 别名]
def maybe_authorize(request, redirect_url = False):
    storage = DjangoORMStorage(GoogleCredentials, 'id', request.user, 'credential')
    credential = storage.get()
    if credential is None or credential.invalid == True:
        flow = create_and_store_flow(request)
        authorize_url = flow.step1_get_authorize_url()
        if redirect_url:
            authorize_url = add_query_param(authorize_url, 'state', redirect_url)
        return (False, authorize_url)
    else:
        return (True, credential) 
开发者ID:CJWorkbench,项目名称:cjworkbench,代码行数:13,代码来源:google_oauth.py

示例3: get_creds

# 需要导入模块: from oauth2client.contrib.django_util import storage [as 别名]
# 或者: from oauth2client.contrib.django_util.storage import DjangoORMStorage [as 别名]
def get_creds(request):
    flow = jsonpickle.decode(request.session['flow'])
    credential = flow.step2_exchange(request.GET.get('code', False))
    storage = DjangoORMStorage(GoogleCredentials, 'id', request.user, 'credential')
    storage.put(credential)
    if request.GET.get('state', False):
        return redirect(unquote_plus(request.GET.get('state')))
    else:
        return HttpResponse(status=200) 
开发者ID:CJWorkbench,项目名称:cjworkbench,代码行数:11,代码来源:google_oauth.py


注:本文中的oauth2client.contrib.django_util.storage.DjangoORMStorage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。