Skip to content

Commit a5edb30

Browse files
committed
Add channel access token v2.1 api
1 parent 507470b commit a5edb30

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

lib/line/bot/client.rb

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,59 @@ def revoke_channel_token(access_token)
102102
post(endpoint, endpoint_path, payload, headers)
103103
end
104104

105+
# Issue channel access token v2.1
106+
#
107+
# @param grant_type [string] client_assertion
108+
#
109+
# @return [Net::HTTPResponse]
110+
def issue_channel_access_token_21(jwt)
111+
channel_id_required
112+
channel_secret_required
113+
114+
endpoint_path = '/oauth2/v2.1/token'
115+
payload = uri.encode_www_form(
116+
grant_type: 'client_credentials',
117+
client_assertion_type: 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer',
118+
client_assertion: jwt
119+
)
120+
headers = { 'content-type' => 'application/x-www-form-urlencoded' }
121+
post(endpoint, endpoint_path, payload, headers)
122+
end
123+
124+
# Revoke channel access token v2.1
125+
#
126+
# @return [Net::HTTPResponse]
127+
def revoke_channel_access_token_21(access_token)
128+
channel_id_required
129+
channel_secret_required
130+
131+
endpoint_path = '/oauth2/v2.1/revoke'
132+
payload = URI.encode_www_form(
133+
client_id: client_id,
134+
client_secret: client_secret,
135+
access_token: access_token
136+
)
137+
headers = { 'Content-Type' => 'application/x-www-form-urlencoded' }
138+
post(endpoint, endpoint_path, payload, headers)
139+
end
140+
141+
# Get all valid channel access token key IDs v2.1
142+
#
143+
# @return [Net::HTTPResponse]
144+
def get_channel_access_token_key_ids_21(jwt)
145+
channel_id_required
146+
channel_secret_required
147+
148+
endpoint_path = '/oauth2/v2.1/kid'
149+
payload = uri.encode_www_form(
150+
grant_type: 'client_credentials',
151+
client_assertion_type: 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer',
152+
client_assertion: jwt
153+
)
154+
headers = { 'content-type' => 'application/x-www-form-urlencoded' }
155+
post(endpoint, endpoint_path, payload, headers)
156+
end
157+
105158
# Push messages to a user using user_id.
106159
#
107160
# @param user_id [String] User Id

0 commit comments

Comments
 (0)