After configuring, run your website, use www. com/login/weixin access to open the corresponding page, but there is no error found: Scope参数错误或没有Scope权限 , in the actual operation, I found social-auth the automatic generation of QR code access link, is less a scope Parameters, and the official QR code access link is this:
Https://open.weixin.qq.com/connect/qrconnect?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code &scope=scope&state=state#wechat_redirect
If the required parameters are 5, state can be omitted, but scope is required, and for Web page authorization access, the scope scope parameter is a fixed value scope=snsapi_login , so we need to social-auth the source code, this parameter value to add, according to your actual site-packages installation path To locate /social/backends/weixin.py the file, as I used to VirtualEnv build the path is:
/home/ubuntu/env/mppython/lib/python2.7/site-packages/social/backends/weixin.py
Open this file and find def auth_params() the contents of this paragraph (original):
def auth_params (self, state=none): AppID, secret = Self.get_key_and_secret () params = { ' AppID ': AppID, ' Redirect_uri ': Self.get_redirect_uri (state), } If self. State_parameter and state: params[' state ') = State if self. Response_type: params[' response_type '] = self. Response_type return params
In the params dictionary, add a scope parameter and modify it as follows:
def auth_params (self, state=none): AppID, secret = Self.get_key_and_secret () params = { ' AppID ': AppID, ' Redirect_uri ': Self.get_redirect_uri (state), ' scope ': ' Snsapi_login ', } if self. State_parameter and state: params[' state ') = State if self. Response_type: params[' response_type '] = self. Response_type return params
After you save, re-run the project and revisit www. domain name. Com/login/weixin can see the effect!