Sha256: 888ccfc981e5a08caf73d401a7e89768840e8eec31a55bbe1a98834ac8a68247

Contents?: true

Size: 1.15 KB

Versions: 16

Compression:

Stored size: 1.15 KB

Contents

module Asana
  module Authentication
    module OAuth2
      # Public: A mechanism to authenticate with an OAuth2 bearer token obtained
      # somewhere, for instance through omniauth-asana.
      #
      # Note: This authentication mechanism doesn't support token refreshing. If
      # you'd like refreshing and you have a refresh token as well as a bearer
      # token, you can generate a proper access token with
      # {AccessTokenAuthentication.from_refresh_token}.
      class BearerTokenAuthentication
        # Public: Initializes a new BearerTokenAuthentication with a plain
        # bearer token.
        #
        # bearer_token - [String] a plain bearer token.
        def initialize(bearer_token)
          @token = bearer_token
        end

        # Public: Configures a Faraday connection injecting its token as an
        # OAuth2 bearer token.
        #
        # connection - [Faraday::Connection] the Faraday connection instance.
        #
        # Returns nothing.
        def configure(connection)
          connection.authorization :Bearer, @token
          connection.request :oauth2, token_type: 'bearer'
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
asana-2.0.0 lib/asana/authentication/oauth2/bearer_token_authentication.rb
asana-1.0.0 lib/asana/authentication/oauth2/bearer_token_authentication.rb
asana-0.10.13 lib/asana/authentication/oauth2/bearer_token_authentication.rb
asana-0.10.12 lib/asana/authentication/oauth2/bearer_token_authentication.rb
asana-0.10.3 lib/asana/authentication/oauth2/bearer_token_authentication.rb
asana-0.10.2 lib/asana/authentication/oauth2/bearer_token_authentication.rb
asana-0.10.1 lib/asana/authentication/oauth2/bearer_token_authentication.rb
asana-0.10.0 lib/asana/authentication/oauth2/bearer_token_authentication.rb
asana-0.9.3 lib/asana/authentication/oauth2/bearer_token_authentication.rb
asana-0.9.2 lib/asana/authentication/oauth2/bearer_token_authentication.rb
asana-0.9.1 lib/asana/authentication/oauth2/bearer_token_authentication.rb
asana-0.9.0 lib/asana/authentication/oauth2/bearer_token_authentication.rb
asana-0.8.1 lib/asana/authentication/oauth2/bearer_token_authentication.rb
asana-0.8.0 lib/asana/authentication/oauth2/bearer_token_authentication.rb
asana-0.6.3 lib/asana/authentication/oauth2/bearer_token_authentication.rb
asana-0.6.2 lib/asana/authentication/oauth2/bearer_token_authentication.rb