Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
weixin_authorize
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ikcrm_common
weixin_authorize
Commits
7ea61e50
Commit
7ea61e50
authored
Jun 24, 2015
by
lanrion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加定制token
parent
0199112f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
3 deletions
+7
-3
lib/weixin_authorize/client.rb
+7
-3
No files found.
lib/weixin_authorize/client.rb
View file @
7ea61e50
...
@@ -15,24 +15,28 @@ module WeixinAuthorize
...
@@ -15,24 +15,28 @@ module WeixinAuthorize
include
Api
::
Template
include
Api
::
Template
attr_accessor
:app_id
,
:app_secret
,
:expired_at
# Time.now + expires_in
attr_accessor
:app_id
,
:app_secret
,
:expired_at
# Time.now + expires_in
attr_accessor
:access_token
,
:redis_key
attr_accessor
:access_token
,
:redis_key
,
:custom_access_token
attr_accessor
:jsticket
,
:jsticket_expired_at
,
:jsticket_redis_key
attr_accessor
:jsticket
,
:jsticket_expired_at
,
:jsticket_redis_key
def
initialize
(
app_id
,
app_secret
,
redis_key
=
nil
)
# options: redis_key, custom_access_token
def
initialize
(
app_id
,
app_secret
,
options
=
{})
@app_id
=
app_id
@app_id
=
app_id
@app_secret
=
app_secret
@app_secret
=
app_secret
@jsticket_expired_at
=
@expired_at
=
Time
.
now
.
to_i
@jsticket_expired_at
=
@expired_at
=
Time
.
now
.
to_i
@redis_key
=
security_redis_key
(
redis_key
||
"weixin_
#{
app_id
}
"
)
@redis_key
=
security_redis_key
(
options
[
:redis_key
]
||
"weixin_
#{
app_id
}
"
)
@jsticket_redis_key
=
security_redis_key
(
"js_sdk_
#{
app_id
}
"
)
@jsticket_redis_key
=
security_redis_key
(
"js_sdk_
#{
app_id
}
"
)
@custom_access_token
=
options
[
:custom_access_token
]
end
end
# return token
# return token
def
get_access_token
def
get_access_token
return
custom_access_token
if
!
custom_access_token
.
nil?
token_store
.
access_token
token_store
.
access_token
end
end
# 检查appid和app_secret是否有效。
# 检查appid和app_secret是否有效。
def
is_valid?
def
is_valid?
return
true
if
!
custom_access_token
.
nil?
token_store
.
valid?
token_store
.
valid?
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