Sha256: dd7b54fc5c191b33cb5a17161dfa0bb1fa971d72b746f7245e08b21da0311dab

Contents?: true

Size: 1.06 KB

Versions: 6

Compression:

Stored size: 1.06 KB

Contents

module BacklogKit
  class Client
    # Methods for OAuth 2.0 authorization
    #
    # @see http://developer.nulab-inc.com/docs/backlog/auth
    module Authorization
      # Create a new access token
      #
      # @param oauth_code [String] Authorization code that you get from the authorization endpoint
      # @return [BacklogKit::Response] The token information
      def create_token(oauth_code)
        params = {
          client_id: client_id,
          client_secret: client_secret,
          grant_type: 'authorization_code',
          code: oauth_code
        }
        params[:redirect_uri] = redirect_uri if redirect_uri
        request(:post, 'oauth2/token', params, true)
      end

      # Refresh an access token
      #
      # @return [BacklogKit::Response] The token information
      def update_token
        params = {
          client_id: client_id,
          client_secret: client_secret,
          grant_type: 'refresh_token',
          refresh_token: refresh_token
        }
        request(:post, 'oauth2/token', params, true)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
backlog_kit-0.19.0 lib/backlog_kit/client/authorization.rb
backlog_kit-0.18.0 lib/backlog_kit/client/authorization.rb
backlog_kit-0.17.0 lib/backlog_kit/client/authorization.rb
backlog_kit-0.16.0 lib/backlog_kit/client/authorization.rb
backlog_kit-0.15.0 lib/backlog_kit/client/authorization.rb
backlog_kit-0.14.0 lib/backlog_kit/client/authorization.rb