Sha256: a6b1a43cb34b1a7259d7bf7abb71c3917e45e8141082cc8d614117e249f031ed

Contents?: true

Size: 766 Bytes

Versions: 3

Compression:

Stored size: 766 Bytes

Contents

module ChatWork
  module Token
    # refresh access_token with refresh_token
    #
    # @param refresh_token [String]
    # @param scope [Array<String>]
    #
    # @return [Hash]
    # @example 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",
    #   }
    def self.refresh_access_token(refresh_token, scope = [])
      params = {
        grant_type:    "refresh_token",
        refresh_token: refresh_token,
      }
      params[:scope] = scope.join(" ") unless scope.empty?

      ChatWork.oauth_client.post("/token", params)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
chatwork-0.7.0 lib/chatwork/token.rb
chatwork-0.6.2 lib/chatwork/token.rb
chatwork-0.6.1 lib/chatwork/token.rb