Class: Line::Bot::V2::ChannelAccessToken::ApiClient

Inherits:
Object
  • Object
show all
Defined in:
lib/line/bot/v2/channel_access_token/api/channel_access_token_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(base_url: nil, http_options: {}) ⇒ ApiClient

Initializes a new Line::Bot::V2::ChannelAccessToken::ApiClient instance.

Examples:

@client ||= Line::Bot::V2::ChannelAccessToken::ApiClient.new(
  http_options: {
    open_timeout: 5,
    read_timeout: 5,
  }
)

Parameters:

  • base_url (String) (defaults to: nil)

    The base URL for requests (optional). Defaults to ‘api.line.me’ if none is provided. You can override this for testing or to use a mock server.

  • http_options (Hash) (defaults to: {})

    HTTP options (same as Net::HTTP options). See: docs.ruby-lang.org/en/3.4/Net/HTTP.html to understand the options.



36
37
38
39
40
41
# File 'lib/line/bot/v2/channel_access_token/api/channel_access_token_client.rb', line 36

def initialize(base_url: nil, http_options: {})
  @http_client = HttpClient.new(
    base_url: base_url || 'https://api.line.me',
    http_options: http_options
  )
end

Instance Method Details

#gets_all_valid_channel_access_token_key_ids(client_assertion_type:, client_assertion:) ⇒ Line::Bot::V2::ChannelAccessToken::ChannelAccessTokenKeyIdsResponse, ...

Gets all valid channel access token key IDs. This requests to GET https://api.line.me/oauth2/v2.1/tokens/kid When you want to get HTTP status code or response headers, use #gets_all_valid_channel_access_token_key_ids_with_http_info instead of this.

Parameters:

  • client_assertion_type (String)

    urn:ietf:params:oauth:client-assertion-type:jwt-bearer

  • client_assertion (String)

    A JSON Web Token (JWT) (opens new window)the client needs to create and sign with the private key.

Returns:

See Also:



89
90
91
92
93
94
95
96
97
98
99
# File 'lib/line/bot/v2/channel_access_token/api/channel_access_token_client.rb', line 89

def gets_all_valid_channel_access_token_key_ids(
  client_assertion_type:,
  client_assertion:
)
  response_body, _status_code, _headers = gets_all_valid_channel_access_token_key_ids_with_http_info(
    client_assertion_type: client_assertion_type,
    client_assertion: client_assertion
  )

  response_body
end

#gets_all_valid_channel_access_token_key_ids_with_http_info(client_assertion_type:, client_assertion:) ⇒ Array(Line::Bot::V2::ChannelAccessToken::ChannelAccessTokenKeyIdsResponse, Integer, Hash{String => String}), Array((String|nil), Integer, Hash{String => String})

Gets all valid channel access token key IDs. This requests to GET https://api.line.me/oauth2/v2.1/tokens/kid This returns an array containing response, HTTP status code, and header in order. Please specify all header keys in lowercase.

Parameters:

  • client_assertion_type (String)

    urn:ietf:params:oauth:client-assertion-type:jwt-bearer

  • client_assertion (String)

    A JSON Web Token (JWT) (opens new window)the client needs to create and sign with the private key.

Returns:

See Also:



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/line/bot/v2/channel_access_token/api/channel_access_token_client.rb', line 52

def gets_all_valid_channel_access_token_key_ids_with_http_info( # steep:ignore MethodBodyTypeMismatch 
  client_assertion_type:, 
  client_assertion:
)
  path = "/oauth2/v2.1/tokens/kid"
  query_params = {
    "client_assertion_type": client_assertion_type,
    "client_assertion": client_assertion
  }.compact

  response = @http_client.get(
    path: path,
    query_params: query_params,
  )

  case response.code.to_i
  when 200
    json = Line::Bot::V2::Utils.deep_underscore(JSON.parse(response.body))
    json.transform_keys! do |key|
      Line::Bot::V2::RESERVED_WORDS.include?(key) ? "_#{key}".to_sym : key
    end
    response_body = Line::Bot::V2::ChannelAccessToken::ChannelAccessTokenKeyIdsResponse.create(json) # steep:ignore InsufficientKeywordArguments
    [response_body, 200, response.each_header.to_h]
  else
    [response.body, response.code.to_i, response.each_header.to_h]
  end
end

#issue_channel_token(grant_type:, client_id:, client_secret:) ⇒ Line::Bot::V2::ChannelAccessToken::IssueShortLivedChannelAccessTokenResponse, ...

Issue short-lived channel access token This requests to POST https://api.line.me/v2/oauth/accessToken When you want to get HTTP status code or response headers, use #issue_channel_token_with_http_info instead of this.

Parameters:

  • grant_type (String)

    client_credentials

  • client_id (String)

    Channel ID.

  • client_secret (String)

    Channel secret.

Returns:

See Also:



161
162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/line/bot/v2/channel_access_token/api/channel_access_token_client.rb', line 161

def issue_channel_token(
  grant_type:,
  client_id:,
  client_secret:
)
  response_body, _status_code, _headers = issue_channel_token_with_http_info(
    grant_type: grant_type,
    client_id: client_id,
    client_secret: client_secret
  )

  response_body
end

#issue_channel_token_by_jwt(grant_type:, client_assertion_type:, client_assertion:) ⇒ Line::Bot::V2::ChannelAccessToken::IssueChannelAccessTokenResponse, ...

Issues a channel access token that allows you to specify a desired expiration date. This method lets you use JWT assertion for authentication. This requests to POST https://api.line.me/oauth2/v2.1/token When you want to get HTTP status code or response headers, use #issue_channel_token_by_jwt_with_http_info instead of this.

Parameters:

  • grant_type (String)

    client_credentials

  • client_assertion_type (String)

    urn:ietf:params:oauth:client-assertion-type:jwt-bearer

  • client_assertion (String)

    A JSON Web Token the client needs to create and sign with the private key of the Assertion Signing Key.

Returns:

See Also:



226
227
228
229
230
231
232
233
234
235
236
237
238
# File 'lib/line/bot/v2/channel_access_token/api/channel_access_token_client.rb', line 226

def issue_channel_token_by_jwt(
  grant_type:,
  client_assertion_type:,
  client_assertion:
)
  response_body, _status_code, _headers = issue_channel_token_by_jwt_with_http_info(
    grant_type: grant_type,
    client_assertion_type: client_assertion_type,
    client_assertion: client_assertion
  )

  response_body
end

#issue_channel_token_by_jwt_with_http_info(grant_type:, client_assertion_type:, client_assertion:) ⇒ Array(Line::Bot::V2::ChannelAccessToken::IssueChannelAccessTokenResponse, Integer, Hash{String => String}), Array((String|nil), Integer, Hash{String => String})

Issues a channel access token that allows you to specify a desired expiration date. This method lets you use JWT assertion for authentication. This requests to POST https://api.line.me/oauth2/v2.1/token This returns an array containing response, HTTP status code, and header in order. Please specify all header keys in lowercase.

Parameters:

  • grant_type (String)

    client_credentials

  • client_assertion_type (String)

    urn:ietf:params:oauth:client-assertion-type:jwt-bearer

  • client_assertion (String)

    A JSON Web Token the client needs to create and sign with the private key of the Assertion Signing Key.

Returns:

See Also:



185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# File 'lib/line/bot/v2/channel_access_token/api/channel_access_token_client.rb', line 185

def issue_channel_token_by_jwt_with_http_info( # steep:ignore MethodBodyTypeMismatch 
  grant_type:, 
  client_assertion_type:, 
  client_assertion:
)
  path = "/oauth2/v2.1/token"

  form_params = {
    "grant_type": grant_type,
    "client_assertion_type": client_assertion_type,
    "client_assertion": client_assertion
  }.compact

  response = @http_client.post_form(
    path: path,
    form_params: form_params,
  )

  case response.code.to_i
  when 200
    json = Line::Bot::V2::Utils.deep_underscore(JSON.parse(response.body))
    json.transform_keys! do |key|
      Line::Bot::V2::RESERVED_WORDS.include?(key) ? "_#{key}".to_sym : key
    end
    response_body = Line::Bot::V2::ChannelAccessToken::IssueChannelAccessTokenResponse.create(json) # steep:ignore InsufficientKeywordArguments
    [response_body, 200, response.each_header.to_h]
  else
    [response.body, response.code.to_i, response.each_header.to_h]
  end
end

#issue_channel_token_with_http_info(grant_type:, client_id:, client_secret:) ⇒ Array(Line::Bot::V2::ChannelAccessToken::IssueShortLivedChannelAccessTokenResponse, Integer, Hash{String => String}), ...

Issue short-lived channel access token This requests to POST https://api.line.me/v2/oauth/accessToken This returns an array containing response, HTTP status code, and header in order. Please specify all header keys in lowercase.

Parameters:

  • grant_type (String)

    client_credentials

  • client_id (String)

    Channel ID.

  • client_secret (String)

    Channel secret.

Returns:

See Also:



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/line/bot/v2/channel_access_token/api/channel_access_token_client.rb', line 112

def issue_channel_token_with_http_info( # steep:ignore MethodBodyTypeMismatch 
  grant_type:, 
  client_id:, 
  client_secret:
)
  path = "/v2/oauth/accessToken"

  form_params = {
    "grant_type": grant_type,
    "client_id": client_id,
    "client_secret": client_secret
  }.compact

  response = @http_client.post_form(
    path: path,
    form_params: form_params,
  )

  case response.code.to_i
  when 200
    json = Line::Bot::V2::Utils.deep_underscore(JSON.parse(response.body))
    json.transform_keys! do |key|
      Line::Bot::V2::RESERVED_WORDS.include?(key) ? "_#{key}".to_sym : key
    end
    response_body = Line::Bot::V2::ChannelAccessToken::IssueShortLivedChannelAccessTokenResponse.create(json) # steep:ignore InsufficientKeywordArguments
    [response_body, 200, response.each_header.to_h]
  when 400
    json = Line::Bot::V2::Utils.deep_underscore(JSON.parse(response.body))
    json.transform_keys! do |key|
      Line::Bot::V2::RESERVED_WORDS.include?(key) ? "_#{key}".to_sym : key
    end
    response_body = Line::Bot::V2::ChannelAccessToken::ErrorResponse.create(json) # steep:ignore InsufficientKeywordArguments
    [response_body, 400, response.each_header.to_h]
  else
    [response.body, response.code.to_i, response.each_header.to_h]
  end
end

#issue_stateless_channel_token(grant_type: nil, client_assertion_type: nil, client_assertion: nil, client_id: nil, client_secret: nil) ⇒ Line::Bot::V2::ChannelAccessToken::IssueStatelessChannelAccessTokenResponse, ...

Deprecated.

This is deprecated. Please use #issue_stateless_channel_token_by_jwt_assertion or #issue_stateless_channel_token_by_client_secret instead.

Issues a new stateless channel access token, which doesn’t have max active token limit unlike the other token types. The newly issued token is only valid for 15 minutes but can not be revoked until it naturally expires. This requests to POST https://api.line.me/oauth2/v3/token When you want to get HTTP status code or response headers, use #issue_stateless_channel_token_with_http_info instead of this.

Parameters:

  • grant_type (String, nil) (defaults to: nil)

    client_credentials

  • client_assertion_type (String, nil) (defaults to: nil)

    URL-encoded value of urn:ietf:params:oauth:client-assertion-type:jwt-bearer

  • client_assertion (String, nil) (defaults to: nil)

    A JSON Web Token the client needs to create and sign with the private key of the Assertion Signing Key.

  • client_id (String, nil) (defaults to: nil)

    Channel ID.

  • client_secret (String, nil) (defaults to: nil)

    Channel secret.

Returns:

See Also:



307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
# File 'lib/line/bot/v2/channel_access_token/api/channel_access_token_client.rb', line 307

def issue_stateless_channel_token(
  grant_type: nil,
  client_assertion_type: nil,
  client_assertion: nil,
  client_id: nil,
  client_secret: nil
)
  response_body, _status_code, _headers = issue_stateless_channel_token_with_http_info( # steep:ignore DeprecatedReference
    grant_type: grant_type,
    client_assertion_type: client_assertion_type,
    client_assertion: client_assertion,
    client_id: client_id,
    client_secret: client_secret
  )

  response_body
end

#issue_stateless_channel_token_by_client_secret(client_id:, client_secret:) ⇒ Line::Bot::V2::ChannelAccessToken::IssueStatelessChannelAccessTokenResponse, ...

Issues a new stateless channel access token by client secret, which doesn’t have max active token limit unlike the other token types. The newly issued token is only valid for 15 minutes but can not be revoked until it naturally expires. This is a convenience wrapper that only requires the parameters needed for client secret authentication. This requests to POST https://api.line.me/oauth2/v3/token When you want to get HTTP status code or response headers, use #issue_stateless_channel_token_by_client_secret_with_http_info instead of this.

Parameters:

  • client_id (String)

    Channel ID.

  • client_secret (String)

    Channel secret.

Returns:

See Also:



567
568
569
570
571
572
573
574
575
576
# File 'lib/line/bot/v2/channel_access_token/api/channel_access_token_client.rb', line 567

def issue_stateless_channel_token_by_client_secret(
  client_id:,
  client_secret:
)
  issue_stateless_channel_token( # steep:ignore DeprecatedReference
    grant_type: 'client_credentials',
    client_id: client_id,
    client_secret: client_secret
  )
end

#issue_stateless_channel_token_by_client_secret_with_http_info(client_id:, client_secret:) ⇒ Array(Line::Bot::V2::ChannelAccessToken::IssueStatelessChannelAccessTokenResponse, Integer, Hash{String => String}), Array((String|nil), Integer, Hash{String => String})

Issues a new stateless channel access token by client secret, which doesn’t have max active token limit unlike the other token types. The newly issued token is only valid for 15 minutes but can not be revoked until it naturally expires. This is a convenience wrapper that only requires the parameters needed for client secret authentication. This requests to POST https://api.line.me/oauth2/v3/token This returns an array containing response, HTTP status code, and header in order. Please specify all header keys in lowercase.

Parameters:

  • client_id (String)

    Channel ID.

  • client_secret (String)

    Channel secret.

Returns:

See Also:



607
608
609
610
611
612
613
614
615
616
# File 'lib/line/bot/v2/channel_access_token/api/channel_access_token_client.rb', line 607

def issue_stateless_channel_token_by_client_secret_with_http_info(
  client_id:,
  client_secret:
)
  issue_stateless_channel_token_with_http_info( # steep:ignore DeprecatedReference
    grant_type: 'client_credentials',
    client_id: client_id,
    client_secret: client_secret
  )
end

#issue_stateless_channel_token_by_jwt_assertion(client_assertion:) ⇒ Line::Bot::V2::ChannelAccessToken::IssueStatelessChannelAccessTokenResponse, ...

Issues a new stateless channel access token by JWT assertion, which doesn’t have max active token limit unlike the other token types. The newly issued token is only valid for 15 minutes but can not be revoked until it naturally expires. This is a convenience wrapper that only requires the parameters needed for JWT assertion authentication. This requests to POST https://api.line.me/oauth2/v3/token When you want to get HTTP status code or response headers, use #issue_stateless_channel_token_by_jwt_assertion_with_http_info instead of this.

Parameters:

  • client_assertion (String)

    A JSON Web Token the client needs to create and sign with the private key of the Assertion Signing Key.

Returns:

See Also:



547
548
549
550
551
552
553
554
555
# File 'lib/line/bot/v2/channel_access_token/api/channel_access_token_client.rb', line 547

def issue_stateless_channel_token_by_jwt_assertion(
  client_assertion:
)
  issue_stateless_channel_token( # steep:ignore DeprecatedReference
    grant_type: 'client_credentials',
    client_assertion_type: 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer',
    client_assertion: client_assertion
  )
end

#issue_stateless_channel_token_by_jwt_assertion_with_http_info(client_assertion:) ⇒ Array(Line::Bot::V2::ChannelAccessToken::IssueStatelessChannelAccessTokenResponse, Integer, Hash{String => String}), Array((String|nil), Integer, Hash{String => String})

Issues a new stateless channel access token by JWT assertion, which doesn’t have max active token limit unlike the other token types. The newly issued token is only valid for 15 minutes but can not be revoked until it naturally expires. This is a convenience wrapper that only requires the parameters needed for JWT assertion authentication. This requests to POST https://api.line.me/oauth2/v3/token This returns an array containing response, HTTP status code, and header in order. Please specify all header keys in lowercase.

Parameters:

  • client_assertion (String)

    A JSON Web Token the client needs to create and sign with the private key of the Assertion Signing Key.

Returns:

See Also:



587
588
589
590
591
592
593
594
595
# File 'lib/line/bot/v2/channel_access_token/api/channel_access_token_client.rb', line 587

def issue_stateless_channel_token_by_jwt_assertion_with_http_info(
  client_assertion:
)
  issue_stateless_channel_token_with_http_info( # steep:ignore DeprecatedReference
    grant_type: 'client_credentials',
    client_assertion_type: 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer',
    client_assertion: client_assertion
  )
end

#issue_stateless_channel_token_with_http_info(grant_type: nil, client_assertion_type: nil, client_assertion: nil, client_id: nil, client_secret: nil) ⇒ Array(Line::Bot::V2::ChannelAccessToken::IssueStatelessChannelAccessTokenResponse, Integer, Hash{String => String}), Array((String|nil), Integer, Hash{String => String})

Deprecated.

This is deprecated. Please use #issue_stateless_channel_token_by_jwt_assertion_with_http_info or #issue_stateless_channel_token_by_client_secret_with_http_info instead.

Issues a new stateless channel access token, which doesn’t have max active token limit unlike the other token types. The newly issued token is only valid for 15 minutes but can not be revoked until it naturally expires. This requests to POST https://api.line.me/oauth2/v3/token This returns an array containing response, HTTP status code, and header in order. Please specify all header keys in lowercase.

Parameters:

  • grant_type (String, nil) (defaults to: nil)

    client_credentials

  • client_assertion_type (String, nil) (defaults to: nil)

    URL-encoded value of urn:ietf:params:oauth:client-assertion-type:jwt-bearer

  • client_assertion (String, nil) (defaults to: nil)

    A JSON Web Token the client needs to create and sign with the private key of the Assertion Signing Key.

  • client_id (String, nil) (defaults to: nil)

    Channel ID.

  • client_secret (String, nil) (defaults to: nil)

    Channel secret.

Returns:

See Also:



256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
# File 'lib/line/bot/v2/channel_access_token/api/channel_access_token_client.rb', line 256

def issue_stateless_channel_token_with_http_info( # steep:ignore MethodBodyTypeMismatch 
  grant_type: nil, 
  client_assertion_type: nil, 
  client_assertion: nil, 
  client_id: nil, 
  client_secret: nil
)
  path = "/oauth2/v3/token"

  form_params = {
    "grant_type": grant_type,
    "client_assertion_type": client_assertion_type,
    "client_assertion": client_assertion,
    "client_id": client_id,
    "client_secret": client_secret
  }.compact

  response = @http_client.post_form(
    path: path,
    form_params: form_params,
  )

  case response.code.to_i
  when 200
    json = Line::Bot::V2::Utils.deep_underscore(JSON.parse(response.body))
    json.transform_keys! do |key|
      Line::Bot::V2::RESERVED_WORDS.include?(key) ? "_#{key}".to_sym : key
    end
    response_body = Line::Bot::V2::ChannelAccessToken::IssueStatelessChannelAccessTokenResponse.create(json) # steep:ignore InsufficientKeywordArguments
    [response_body, 200, response.each_header.to_h]
  else
    [response.body, response.code.to_i, response.each_header.to_h]
  end
end

#revoke_channel_token(access_token:) ⇒ String?

Revoke short-lived or long-lived channel access token This requests to POST https://api.line.me/v2/oauth/revoke When you want to get HTTP status code or response headers, use #revoke_channel_token_with_http_info instead of this.

Parameters:

  • access_token (String)

    Channel access token

Returns:

  • (String, nil)

    when HTTP status code is 200

  • (String, nil)

    when other HTTP status code is returned. This String is HTTP response body itself.

See Also:



363
364
365
366
367
368
369
370
371
# File 'lib/line/bot/v2/channel_access_token/api/channel_access_token_client.rb', line 363

def revoke_channel_token(
  access_token:
)
  response_body, _status_code, _headers = revoke_channel_token_with_http_info(
    access_token: access_token
  )

  response_body
end

#revoke_channel_token_by_jwt(client_id:, client_secret:, access_token:) ⇒ String?

Revoke channel access token v2.1 This requests to POST https://api.line.me/oauth2/v2.1/revoke When you want to get HTTP status code or response headers, use #revoke_channel_token_by_jwt_with_http_info instead of this.

Parameters:

  • client_id (String)

    Channel ID

  • client_secret (String)

    Channel Secret

  • access_token (String)

    Channel access token

Returns:

  • (String, nil)

    when HTTP status code is 200

  • (String, nil)

    when other HTTP status code is returned. This String is HTTP response body itself.

See Also:



419
420
421
422
423
424
425
426
427
428
429
430
431
# File 'lib/line/bot/v2/channel_access_token/api/channel_access_token_client.rb', line 419

def revoke_channel_token_by_jwt(
  client_id:,
  client_secret:,
  access_token:
)
  response_body, _status_code, _headers = revoke_channel_token_by_jwt_with_http_info(
    client_id: client_id,
    client_secret: client_secret,
    access_token: access_token
  )

  response_body
end

#revoke_channel_token_by_jwt_with_http_info(client_id:, client_secret:, access_token:) ⇒ Array((String|nil), Integer, Hash{String => String})

Revoke channel access token v2.1 This requests to POST https://api.line.me/oauth2/v2.1/revoke This returns an array containing response, HTTP status code, and header in order. Please specify all header keys in lowercase.

Parameters:

  • client_id (String)

    Channel ID

  • client_secret (String)

    Channel Secret

  • access_token (String)

    Channel access token

Returns:

  • (Array((String|nil), Integer, Hash{String => String}))

    when HTTP status code is 200

  • (Array((String|nil), Integer, Hash{String => String}))

    when other HTTP status code is returned. String is HTTP response body itself.

See Also:



383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
# File 'lib/line/bot/v2/channel_access_token/api/channel_access_token_client.rb', line 383

def revoke_channel_token_by_jwt_with_http_info( # steep:ignore MethodBodyTypeMismatch 
  client_id:, 
  client_secret:, 
  access_token:
)
  path = "/oauth2/v2.1/revoke"

  form_params = {
    "client_id": client_id,
    "client_secret": client_secret,
    "access_token": access_token
  }.compact

  response = @http_client.post_form(
    path: path,
    form_params: form_params,
  )

  case response.code.to_i
  when 200
    [response.body, 200, response.each_header.to_h]
  else
    [response.body, response.code.to_i, response.each_header.to_h]
  end
end

#revoke_channel_token_with_http_info(access_token:) ⇒ Array((String|nil), Integer, Hash{String => String})

Revoke short-lived or long-lived channel access token This requests to POST https://api.line.me/v2/oauth/revoke This returns an array containing response, HTTP status code, and header in order. Please specify all header keys in lowercase.

Parameters:

  • access_token (String)

    Channel access token

Returns:

  • (Array((String|nil), Integer, Hash{String => String}))

    when HTTP status code is 200

  • (Array((String|nil), Integer, Hash{String => String}))

    when other HTTP status code is returned. String is HTTP response body itself.

See Also:



333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
# File 'lib/line/bot/v2/channel_access_token/api/channel_access_token_client.rb', line 333

def revoke_channel_token_with_http_info( # steep:ignore MethodBodyTypeMismatch 
  access_token:
)
  path = "/v2/oauth/revoke"

  form_params = {
    "access_token": access_token
  }.compact

  response = @http_client.post_form(
    path: path,
    form_params: form_params,
  )

  case response.code.to_i
  when 200
    [response.body, 200, response.each_header.to_h]
  else
    [response.body, response.code.to_i, response.each_header.to_h]
  end
end

#verify_channel_token(access_token:) ⇒ Line::Bot::V2::ChannelAccessToken::VerifyChannelAccessTokenResponse, ...

Verify the validity of short-lived and long-lived channel access tokens This requests to POST https://api.line.me/v2/oauth/verify When you want to get HTTP status code or response headers, use #verify_channel_token_with_http_info instead of this.

Parameters:

  • access_token (String)

    A short-lived or long-lived channel access token.

Returns:

See Also:



476
477
478
479
480
481
482
483
484
# File 'lib/line/bot/v2/channel_access_token/api/channel_access_token_client.rb', line 476

def verify_channel_token(
  access_token:
)
  response_body, _status_code, _headers = verify_channel_token_with_http_info(
    access_token: access_token
  )

  response_body
end

#verify_channel_token_by_jwt(access_token:) ⇒ Line::Bot::V2::ChannelAccessToken::VerifyChannelAccessTokenResponse, ...

You can verify whether a Channel access token with a user-specified expiration (Channel Access Token v2.1) is valid. This requests to GET https://api.line.me/oauth2/v2.1/verify When you want to get HTTP status code or response headers, use #verify_channel_token_by_jwt_with_http_info instead of this.

Parameters:

  • access_token (String)

    Channel access token with a user-specified expiration (Channel Access Token v2.1).

Returns:

See Also:



528
529
530
531
532
533
534
535
536
# File 'lib/line/bot/v2/channel_access_token/api/channel_access_token_client.rb', line 528

def verify_channel_token_by_jwt(
  access_token:
)
  response_body, _status_code, _headers = verify_channel_token_by_jwt_with_http_info(
    access_token: access_token
  )

  response_body
end

#verify_channel_token_by_jwt_with_http_info(access_token:) ⇒ Array(Line::Bot::V2::ChannelAccessToken::VerifyChannelAccessTokenResponse, Integer, Hash{String => String}), Array((String|nil), Integer, Hash{String => String})

You can verify whether a Channel access token with a user-specified expiration (Channel Access Token v2.1) is valid. This requests to GET https://api.line.me/oauth2/v2.1/verify This returns an array containing response, HTTP status code, and header in order. Please specify all header keys in lowercase.

Parameters:

  • access_token (String)

    Channel access token with a user-specified expiration (Channel Access Token v2.1).

Returns:

See Also:



494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
# File 'lib/line/bot/v2/channel_access_token/api/channel_access_token_client.rb', line 494

def verify_channel_token_by_jwt_with_http_info( # steep:ignore MethodBodyTypeMismatch 
  access_token:
)
  path = "/oauth2/v2.1/verify"
  query_params = {
    "access_token": access_token
  }.compact

  response = @http_client.get(
    path: path,
    query_params: query_params,
  )

  case response.code.to_i
  when 200
    json = Line::Bot::V2::Utils.deep_underscore(JSON.parse(response.body))
    json.transform_keys! do |key|
      Line::Bot::V2::RESERVED_WORDS.include?(key) ? "_#{key}".to_sym : key
    end
    response_body = Line::Bot::V2::ChannelAccessToken::VerifyChannelAccessTokenResponse.create(json) # steep:ignore InsufficientKeywordArguments
    [response_body, 200, response.each_header.to_h]
  else
    [response.body, response.code.to_i, response.each_header.to_h]
  end
end

#verify_channel_token_with_http_info(access_token:) ⇒ Array(Line::Bot::V2::ChannelAccessToken::VerifyChannelAccessTokenResponse, Integer, Hash{String => String}), Array((String|nil), Integer, Hash{String => String})

Verify the validity of short-lived and long-lived channel access tokens This requests to POST https://api.line.me/v2/oauth/verify This returns an array containing response, HTTP status code, and header in order. Please specify all header keys in lowercase.

Parameters:

  • access_token (String)

    A short-lived or long-lived channel access token.

Returns:

See Also:



441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
# File 'lib/line/bot/v2/channel_access_token/api/channel_access_token_client.rb', line 441

def verify_channel_token_with_http_info( # steep:ignore MethodBodyTypeMismatch 
  access_token:
)
  path = "/v2/oauth/verify"

  form_params = {
    "access_token": access_token
  }.compact

  response = @http_client.post_form(
    path: path,
    form_params: form_params,
  )

  case response.code.to_i
  when 200
    json = Line::Bot::V2::Utils.deep_underscore(JSON.parse(response.body))
    json.transform_keys! do |key|
      Line::Bot::V2::RESERVED_WORDS.include?(key) ? "_#{key}".to_sym : key
    end
    response_body = Line::Bot::V2::ChannelAccessToken::VerifyChannelAccessTokenResponse.create(json) # steep:ignore InsufficientKeywordArguments
    [response_body, 200, response.each_header.to_h]
  else
    [response.body, response.code.to_i, response.each_header.to_h]
  end
end