Commit d2f7bb1d7580bc287770c2eeb62a9a79a4fd64c2
1 parent
7d9d62e4
Exists in
master
添加第三方应用授权URL生成API
Showing
4 changed files
with
16 additions
and
0 deletions
Show diff stats
README.md
... | ... | @@ -169,6 +169,9 @@ suite_api.set_agent(auth_corpid, permanent_code, agent_info) |
169 | 169 | |
170 | 170 | # 调用企业接口所需的access_token |
171 | 171 | suite_api.get_crop_token(auth_corpid, permanent_code) |
172 | + | |
173 | +# 生成授权URL | |
174 | +suite_api.auth_url(code, uri, state="suite") | |
172 | 175 | ``` |
173 | 176 | |
174 | 177 | ### 应用套件的回调通知处理 | ... | ... |
lib/qy_wechat_api.rb
lib/qy_wechat_api/api/service/suite.rb
... | ... | @@ -55,6 +55,17 @@ module QyWechatApi |
55 | 55 | http_post("get_crop_token", params) |
56 | 56 | end |
57 | 57 | |
58 | + # https://qy.weixin.qq.com/cgi-bin/loginpage?suite_id=$suite_id$&pre_auth_code=$pre_auth_code$&redirect_uri=$redirect_uri$&state=$state$ | |
59 | + def auth_url(code, uri, state="suite") | |
60 | + params = { | |
61 | + suite_id: suite_id, | |
62 | + pre_auth_code: code, | |
63 | + redirect_uri: uri, | |
64 | + state: state | |
65 | + }.to_query | |
66 | + "#{QyWechatApi::ENDPOINT_URL}/loginpage?#{params}" | |
67 | + end | |
68 | + | |
58 | 69 | private |
59 | 70 | |
60 | 71 | def base_url | ... | ... |
qy_wechat_api.gemspec
... | ... | @@ -23,6 +23,7 @@ Gem::Specification.new do |spec| |
23 | 23 | # A streaming JSON parsing and encoding library for Ruby (C bindings to yajl) |
24 | 24 | # https://github.com/brianmario/yajl-ruby |
25 | 25 | spec.add_dependency "yajl-ruby", "~> 1.2.0" |
26 | + spec.add_dependency "activesupport" | |
26 | 27 | |
27 | 28 | spec.add_dependency "carrierwave", "~> 0.10.0" |
28 | 29 | spec.add_dependency 'mini_magick', '~> 3.7.0' | ... | ... |