Commit f88d9746 by mingyuan

new app get access token

parent dc2542da
...@@ -7,7 +7,7 @@ GIT ...@@ -7,7 +7,7 @@ GIT
GIT GIT
remote: https://github.com/work-design/rails_com.git remote: https://github.com/work-design/rails_com.git
revision: 806cc320be3056c8c53cc6c8d89461216e898546 revision: 96b28af01b4a3aaca389ea4b44b33e869e01a67c
specs: specs:
rails_com (1.2.9) rails_com (1.2.9)
acme-client acme-client
......
require 'dingtalk/http_client' require 'dingtalk/http_client'
require 'dingtalk/api/base' require 'dingtalk/api/base'
require 'dingtalk/api/base_new'
...@@ -3,7 +3,15 @@ module Dingtalk::Api ...@@ -3,7 +3,15 @@ module Dingtalk::Api
BASE = 'https://api.dingtalk.com/' BASE = 'https://api.dingtalk.com/'
def token def token
@client.post 'v1.0/oauth2/userAccessToken', { clientId: app.app_key, clientSecret: app.app_secret }.to_json, base: BASE payload = {
appKey: app.app_key,
appSecret: app.app_secret,
}
r = @client.post 'v1.0/oauth2/accessToken', payload.to_json, base: BASE
{
'access_token' => r['accessToken'],
'expires_in' => r['expireIn']
}
end end
end end
......
...@@ -11,7 +11,6 @@ module Dingtalk ...@@ -11,7 +11,6 @@ module Dingtalk
attribute :corp_id, :string attribute :corp_id, :string
attribute :access_token, :string attribute :access_token, :string
attribute :access_token_expires_at, :datetime attribute :access_token_expires_at, :datetime
attribute :refresh_token, :string
attribute :jsapi_ticket, :string attribute :jsapi_ticket, :string
attribute :oauth2_state, :string attribute :oauth2_state, :string
attribute :jsapi_ticket_expires_at, :datetime attribute :jsapi_ticket_expires_at, :datetime
...@@ -42,9 +41,9 @@ module Dingtalk ...@@ -42,9 +41,9 @@ module Dingtalk
access_token_expires_at > Time.current access_token_expires_at > Time.current
end end
def jsapi_ticket def get_jsapi_ticket
if jsapi_ticket_valid? if jsapi_ticket_valid?
super jsapi_ticket
else else
refresh_jsapi_ticket refresh_jsapi_ticket
end end
......
module Dingtalk::Model module Dingtalk
module App::NewApp module Model::App::NewApp
def api def api
return @api if defined? @api return @api if defined? @api
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment