lazyad 0.0.7__py3-none-any.whl → 0.0.8__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of lazyad might be problematic. Click here for more details.

lazyad/open/qq.py CHANGED
@@ -16,14 +16,60 @@ def make_nonce():
16
16
  return str(time.time()) + str(random.randint(0, 999999))
17
17
 
18
18
 
19
- def oauth_token(
19
+ def oauth_token2(
20
+ app_id,
21
+ app_secret,
22
+ redirect_uri,
23
+ grant_type='authorization_code',
24
+ auth_code=None,
25
+ refresh_token=None,
26
+ ):
27
+ """
28
+ OAuth 2.0 授权
29
+ 获取/刷新token
30
+ 相关文档:https://developers.e.qq.com/docs/start/authorization
31
+ :param auth_code:
32
+ :param app_id:
33
+ :param app_secret:
34
+ :param grant_type: 请求的类型,可选值:authorization_code(授权码方式获取 token)、refresh_token(刷新 token)
35
+ :param refresh_token:
36
+ :param redirect_uri:
37
+ :return:
38
+ """
39
+ redirect_uri = f'{redirect_uri}?app_id={app_id}'
40
+
41
+ url = 'https://api.e.qq.com/oauth/token'
42
+ params = {
43
+ 'client_id': app_id,
44
+ 'client_secret': app_secret,
45
+ 'grant_type': grant_type
46
+ }
47
+ if auth_code:
48
+ params['authorization_code'] = auth_code
49
+ if refresh_token:
50
+ params['refresh_token'] = refresh_token
51
+ if redirect_uri:
52
+ params['redirect_uri'] = redirect_uri
53
+
54
+ for k in params:
55
+ if type(params[k]) is not str:
56
+ params[k] = json.dumps(params[k])
57
+
58
+ return lazyrequests.lazy_requests(
59
+ method="GET",
60
+ url=url,
61
+ params=params
62
+ )
63
+
64
+
65
+ def oauth_token3(
20
66
  access_token,
21
67
  app_id,
22
68
  app_secret,
69
+ redirect_uri,
23
70
  grant_type='authorization_code',
24
71
  auth_code=None,
25
72
  refresh_token=None,
26
- redirect_uri=None
27
73
  ):
28
74
  """
29
75
  获取/刷新token
@@ -34,12 +80,10 @@ def oauth_token(
34
80
  :param app_secret:
35
81
  :param grant_type: 请求的类型,可选值:authorization_code(授权码方式获取 token)、refresh_token(刷新 token)
36
82
  :param refresh_token:
37
- :param redirect_uri:
83
+ :param redirect_uri: 回调地址
38
84
  :return:
39
85
  """
40
- if grant_type and not redirect_uri:
41
- redirect_uri = f'https://open.fanshang888.com/api/cache/receive/open_api/ad/ad_developer/qq/callback?app_id={app_id}'
42
-
86
+ redirect_uri = f'{redirect_uri}?app_id={app_id}'
43
87
  url = 'https://api.e.qq.com/v3.0/oauth/token'
44
88
  params = {
45
89
  'access_token': access_token,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lazyad
3
- Version: 0.0.7
3
+ Version: 0.0.8
4
4
  Summary: 基于Python的懒人包-适用于广告投放模块
5
5
  Home-page: https://gitee.com/ZeroSeeker/lazyad
6
6
  Author: ZeroSeeker
@@ -4,8 +4,8 @@ lazyad/crawlers/chuangliang.py,sha256=mVlfN5fipQdRc6STuC0B68ntGCU23I1PF2sD5q2jnc
4
4
  lazyad/crawlers/oceanengine.py,sha256=kjBEpCb_h5OpodCTqzvXd5MBBwAuw3Oq5UKWoTCXrQM,4540
5
5
  lazyad/crawlers/qq.py,sha256=5W5xVOmRtYRBhuFtrbX9XcrdmgeiV71zIIAtqF44io4,3060
6
6
  lazyad/open/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- lazyad/open/qq.py,sha256=5fZdnizaaACBhhpP4IG4iPAQCG-pZ9L-oLNgcey5qCI,1780
8
- lazyad-0.0.7.dist-info/METADATA,sha256=qbQma-IHYQQel6SHraDXey65QeQ9Zq1MGvtpqvUQW6Y,1694
9
- lazyad-0.0.7.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
10
- lazyad-0.0.7.dist-info/top_level.txt,sha256=RAPjtj4gZYpsKAM3fAQrWyyn84xjdRuaiUS76gx6eNs,7
11
- lazyad-0.0.7.dist-info/RECORD,,
7
+ lazyad/open/qq.py,sha256=0bxNsUF8I8xgkujZ2ni1UYzeBC4ATcGC2azNJHL4oWQ,2886
8
+ lazyad-0.0.8.dist-info/METADATA,sha256=VnnUKrCnmLsONjrLJFx89DwMZBjvoWpi4B08o3BugjA,1694
9
+ lazyad-0.0.8.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
10
+ lazyad-0.0.8.dist-info/top_level.txt,sha256=RAPjtj4gZYpsKAM3fAQrWyyn84xjdRuaiUS76gx6eNs,7
11
+ lazyad-0.0.8.dist-info/RECORD,,
File without changes