Class: OAuth::Token — Documentation by YARD 0.9.44

# Class: OAuth::Token

Inherits:
  Object
  - Object
  - OAuth::Token
  show all

Includes:
  AUTH_SANITIZER::FilteredAttributes, Helper

Defined in:
  lib/oauth/tokens/token.rb

## Overview

Superclass for the various tokens used by OAuth.

Includes {OAuth::AUTH_SANITIZER::FilteredAttributes} so inspect output redacts the
token value and token secret while leaving object identity and non-sensitive
fields visible.

## Direct Known Subclasses

ConsumerToken, ServerToken

## Instance Attribute Summary collapse

- #secret ⇒ String

  OAuth token secret (redacted in `#inspect`).

- #token ⇒ String

  OAuth token value (redacted in `#inspect`).

## Instance Method Summary collapse

- #initialize(token, secret) ⇒ Token constructor

  A new instance of Token.

- #to_query ⇒ Object

### Methods included from Helper

_escape, escape, generate_key, generate_timestamp, normalize, normalize_nested_query, parse_header, stringify_keys, unescape

## Constructor Details

### #initialize(token, secret) ⇒ `Token`

Returns a new instance of Token.

    22
    23
    24
    25
    # File 'lib/oauth/tokens/token.rb', line 22

    def initialize(token, secret)
      @token = token
      @secret = secret
    end

## Instance Attribute Details

### #secret ⇒ `String`

Returns OAuth token secret (redacted in `#inspect`).

Returns:

- (`String`) —

  OAuth token secret (redacted in `#inspect`)

    19
    # File 'lib/oauth/tokens/token.rb', line 19

    attr_accessor :token, :secret

### #token ⇒ `String`

Returns OAuth token value (redacted in `#inspect`).

Returns:

- (`String`) —

  OAuth token value (redacted in `#inspect`)

    19
    20
    21
    # File 'lib/oauth/tokens/token.rb', line 19

    def token
      @token
    end

## Instance Method Details

### #to_query ⇒ `Object`

    27
    28
    29
    # File 'lib/oauth/tokens/token.rb', line 27

    def to_query
      "oauth_token=#{escape(token)}&oauth_token_secret=#{escape(secret)}"
    end