(appname, scope=None, redirect_uri=None, required=True,
                response=None, state="", methods=None, bind=False)
return decorator
微信网页授权
    :param appname: WeChatApp的name
    :param scope: 默认WeChatSNSScope.BASE, 可选WeChatSNSScope.USERINFO
    :type scope: str or iterable
    :param redirect_uri: 未授权时的重定向地址 当未设置response时将自动执行授权
                        当ajax请求时默认取referrer 否则取当前地址
                        注意 请不要在地址上带有code及state参数 否则可能引发问题
    :type redirect_uri: str or Callable[
        [
            django.http.request.HttpRequest,
            *args,
            **kwargs
        ],
        str
    ]
    :param state: 授权时需要携带的state
    :type state: str
                 or Callable[
                    [
                        django.http.request.HttpRequest,
                        *args,
                        **kwargs
                    ],
                    str
                 ]
    :param required: 真值必须授权 否则不授权亦可继续访问(只检查session)
    :param response: 未授权的返回 接受一个
    :type response: django.http.response.HttpResponse
                    or Callable[
                        [
                            django.http.request.HttpRequest,
                            *args,
                            **kwargs
                        ],
                        django.http.response.HttpResponse
                    ]
    :param methods: 允许的HTTP请求方法,默认仅GET
    :type methods: tuple

    使用示例:

        @wechat_auth("your_app_name")
        def your_view(request, *args, **kwargs):
            # request是一个``wechat_django.requests.WeChatOAuthRequest对象``
            user = request.wechat.user
微信网页授权
    :param appname: WeChatApp的name
    :param scope: 默认WeChatSNSScope.BASE, 可选WeChatSNSScope.USERINFO
    :type scope: str or iterable
    :param redirect_uri: 未授权时的重定向地址 当未设置response时将自动执行授权
                        当ajax请求时默认取referrer 否则取当前地址
                        注意 请不要在地址上带有code及state参数 否则可能引发问题
    :type redirect_uri: str or Callable[
        [
            django.http.request.HttpRequest,
            *args,
            **kwargs
        ],
        str
    ]
    :param state: 授权时需要携带的state
    :type state: str
                 or Callable[
                    [
                        django.http.request.HttpRequest,
                        *args,
                        **kwargs
                    ],
                    str
                 ]
    :param required: 真值必须授权 否则不授权亦可继续访问(只检查session)
    :param response: 未授权的返回 接受一个
    :type response: django.http.response.HttpResponse
                    or Callable[
                        [
                            django.http.request.HttpRequest,
                            *args,
                            **kwargs
                        ],
                        django.http.response.HttpResponse
                    ]
    :param methods: 允许的HTTP请求方法,默认仅GET
    :type methods: tuple
微信网页授权 : param appname : WeChatApp的name : param scope : 默认WeChatSNSScope . BASE 可选WeChatSNSScope . USERINFO : type scope : str or iterable : param redirect_uri : 未授权时的重定向地址 当未设置response时将自动执行授权 当ajax请求时默认取referrer 否则取当前地址 注意 请不要在地址上带有code及state参数 否则可能引发问题 : type redirect_uri : str or Callable [ [ django . http . request . HttpRequest * args ** kwargs ] str ] : param state : 授权时需要携带的state : type state : str or Callable [ [ django . http . request . HttpRequest * args ** kwargs ] str ] : param required : 真值必须授权 否则不授权亦可继续访问 ( 只检查session ) : param response : 未授权的返回 接受一个 : type response : django . http . response . HttpResponse or Callable [ [ django . http . request . HttpRequest * args ** kwargs ] django . http . response . HttpResponse ] : param methods : 允许的HTTP请求方法 默认仅GET : type methods : tuple
def wechat_auth(appname, scope=None, redirect_uri=None, required=True,
                response=None, state="", methods=None, bind=False):
    """
    微信网页授权
    :param appname: WeChatApp的name
    :param scope: 默认WeChatSNSScope.BASE, 可选WeChatSNSScope.USERINFO
    :type scope: str or iterable
    :param redirect_uri: 未授权时的重定向地址 当未设置response时将自动执行授权
                        当ajax请求时默认取referrer 否则取当前地址
                        注意 请不要在地址上带有code及state参数 否则可能引发问题
    :type redirect_uri: str or Callable[
        [
            django.http.request.HttpRequest,
            *args,
            **kwargs
        ],
        str
    ]
    :param state: 授权时需要携带的state
    :type state: str
                 or Callable[
                    [
                        django.http.request.HttpRequest,
                        *args,
                        **kwargs
                    ],
                    str
                 ]
    :param required: 真值必须授权 否则不授权亦可继续访问(只检查session)
    :param response: 未授权的返回 接受一个
    :type response: django.http.response.HttpResponse
                    or Callable[
                        [
                            django.http.request.HttpRequest,
                            *args,
                            **kwargs
                        ],
                        django.http.response.HttpResponse
                    ]
    :param methods: 允许的HTTP请求方法,默认仅GET
    :type methods: tuple

    使用示例:

        @wechat_auth("your_app_name")
        def your_view(request, *args, **kwargs):
            # request是一个``wechat_django.requests.WeChatOAuthRequest对象``
            user = request.wechat.user
    """

    methods = methods or ("GET",)

    def decorator(func):
        @wraps(func)
        def view(self, request, *args, **kwargs):
            return func(request, *args, **kwargs)

        attrs = {method.lower(): func if bind else view for method in methods}
        attrs["appname"] = appname
        View = type(str("WeChatOAuthView"), (WeChatOAuthView,), attrs)

        return View.as_view(appname=appname, scope=scope,
                            redirect_uri=redirect_uri, required=required,
                            response=response, state=state)
    return decorator
def wechat_auth ( appname , scope = None , redirect_uri = None , required = True , response = None , state = "" , methods = None , bind = False ) : methods = methods or ( "GET" , ) def decorator ( func ) : @ wraps ( func ) def view ( self , request , * args , * * kwargs ) : return func ( request , * args , * * kwargs ) attrs = { method . lower ( ) : func if bind else view for method in methods } attrs [ "appname" ] = appname View = type ( str ( "WeChatOAuthView" ) , ( WeChatOAuthView , ) , attrs ) return View . as_view ( appname = appname , scope = scope , redirect_uri = redirect_uri , required = required , response = response , state = state ) return decorator