Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
rails_dingtalk
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
other
rails_dingtalk
Commits
65f09bee
Commit
65f09bee
authored
Sep 06, 2021
by
mingyuan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix err
parent
d4740fad
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
11 deletions
+12
-11
new_app.rb
app/models/dingtalk/model/app/new_app.rb
+12
-11
No files found.
app/models/dingtalk/model/app/new_app.rb
View file @
65f09bee
...
@@ -28,21 +28,22 @@ module Dingtalk
...
@@ -28,21 +28,22 @@ module Dingtalk
grantType:
'authorization_code'
grantType:
'authorization_code'
}
}
r
=
HTTPX
.
post
'https://api.dingtalk.com/v1.0/oauth2/userAccessToken'
,
json:
h
r
=
HTTPX
.
post
'https://api.dingtalk.com/v1.0/oauth2/userAccessToken'
,
json:
h
result
=
JSON
.
parse
(
r
.
body
.
to_s
)
token_info
=
JSON
.
parse
(
r
.
body
.
to_s
)
logger
.
debug
result
logger
.
debug
result
info
=
HTTPX
.
post
'https://api.dingtalk.com/v1.0/contact/users/me'
,
headers:
{
'x-acs-dingtalk-access-token'
:
r
[
'accessToken'
]
}
info
=
HTTPX
.
post
'https://api.dingtalk.com/v1.0/contact/users/me'
,
headers:
{
'x-acs-dingtalk-access-token'
:
r
[
'accessToken'
]
}
logger
.
debug
info
profile_info
=
JSON
.
parse
(
info
.
body
.
to_s
)
logger
.
debug
profile_info
#binding.break
#binding.break
dingtalk_user
=
dingtalk_users
.
find_or_initialize_by
(
uid:
info
[
'openId'
])
dingtalk_user
=
dingtalk_users
.
find_or_initialize_by
(
uid:
profile_
info
[
'openId'
])
dingtalk_user
.
access_token
=
r
[
'accessToken'
]
dingtalk_user
.
access_token
=
token_info
[
'accessToken'
]
dingtalk_user
.
expires_at
=
Time
.
current
+
r
[
'expireIn'
].
to_i
dingtalk_user
.
expires_at
=
Time
.
current
+
token_info
[
'expireIn'
].
to_i
dingtalk_user
.
refresh_token
=
r
[
'refreshToken'
]
dingtalk_user
.
refresh_token
=
token_info
[
'refreshToken'
]
dingtalk_user
.
unionid
=
info
[
'unionId'
]
dingtalk_user
.
unionid
=
profile_
info
[
'unionId'
]
dingtalk_user
.
name
=
info
[
'nick'
]
dingtalk_user
.
name
=
profile_
info
[
'nick'
]
dingtalk_user
.
avatar_url
=
info
[
'avatarUrl'
]
dingtalk_user
.
avatar_url
=
profile_
info
[
'avatarUrl'
]
dingtalk_user
.
identity
=
info
[
'mobile'
]
dingtalk_user
.
identity
=
profile_
info
[
'mobile'
]
dingtalk_user
.
extra
=
info
.
slice
(
'email'
,
'stateCode'
)
dingtalk_user
.
extra
=
profile_
info
.
slice
(
'email'
,
'stateCode'
)
dingtalk_user
dingtalk_user
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment