File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1717weixin /.ropeproject /
1818
1919# test
20- test_example.py
20+ # test_example.py
2121test_settings.py
Original file line number Diff line number Diff line change 1+ # -*- coding: utf-8 -*-
2+
3+ from weixin .client import WeixinAPI
4+ from weixin .oauth2 import OAuth2AuthExchangeError
5+
6+ APP_ID = "your app id"
7+ APP_SECRET = "your secret"
8+ REDIRECT_URI = "http://www.exmple.com"
9+
10+
11+ code = "0418f2c46cd26e4f9eee5bf03320662M"
12+
13+ api = WeixinAPI (appid = APP_ID , app_secret = APP_SECRET , redirect_uri = REDIRECT_URI )
14+
15+ try :
16+ pass
17+ # print api.get_authorize_login_url(scope=("snsapi_login",))
18+ # print api.exchange_code_for_access_token(code=code)
19+ except OAuth2AuthExchangeError as e :
20+ print (e )
21+
22+
23+ auth_info = {
24+ "access_token" : "OezXcEiiBSKSxW0eoylIeGXVgVFIUy2pK5I7TVatC5MGtVqTIWjtyV5Pax8ZLiWw-NdEN9dPkEX8Yewsve2AktmzS0gmbvzRKO49l6sxHRfhXg1no5ObdGufYhRIubP2m3FUdv-Cop3t3S_xwMbBWQ" ,
25+ "refresh_token" : "OezXcEiiBSKSxW0eoylIeGXVgVFIUy2pK5I7TVatC5MGtVqTIWjtyV5Pax8ZLiWw44bjXRXdmPsclqGIjWs777H3p00QI9a3hzX265Uq9fPJZttNQApdCRPbySXDfofbjniiwsVJiT7fTv7j5jCAxg" ,
26+ "openid" : u"oV02tuA8Wt6Kk7S0pVydThYvmSJA" ,
27+ "expires_in" : 7200 ,
28+ "scope" : u"snsapi_login" ,
29+ }
30+
31+ try :
32+ api .exchange_refresh_token_for_access_token (
33+ refresh_token = auth_info ["refresh_token" ]
34+ )
35+ except OAuth2AuthExchangeError :
36+ pass
37+ api = WeixinAPI (access_token = auth_info ["access_token" ])
38+ r = api .user (openid = auth_info ["openid" ])
39+ print (r )
40+ v = api .validate_token (openid = auth_info ["openid" ])
41+ print (v )
You can’t perform that action at this time.
0 commit comments