Module: ChatWork::OAuthClient::TokenMethods

Included in:
ChatWork::OAuthClient
Defined in:
lib/chatwork/oauth_client/token_methods.rb

Instance Method Summary collapse

Instance Method Details

#refresh_access_token(refresh_token, scope = []) ⇒ Hash

refresh access_token with refresh_token

Examples:

response

{
  "access_token" => "new_access_token",
  "token_type" => "Bearer",
  "expires_in" => "1800",
  "refresh_token" => "refresh_token",
  "scope" => "users.all:read rooms.all:read_write contacts.all:read_write",
}

Parameters:

  • refresh_token (String)
  • scope (Array<String>) (defaults to: [])

Returns:

  • (Hash)


16
17
18
19
20
21
22
23
24
# File 'lib/chatwork/oauth_client/token_methods.rb', line 16

def refresh_access_token(refresh_token, scope = [])
  params = {
    grant_type:    "refresh_token",
    refresh_token: refresh_token,
  }
  params[:scope] = scope.join(" ") unless scope.empty?

  post("/token", params)
end