Class: OAuth::Server — Documentation by YARD 0.9.44

# Class: OAuth::Server

Inherits:
  Object
  - Object
  - OAuth::Server
  show all

Includes:
  Helper

Defined in:
  lib/oauth/server.rb

## Overview

This is mainly used to create consumer credentials and can pretty much be ignored if you want to create your own

## Constant Summary collapse

@@server_paths =

      {
        request_token_path: "/oauth/request_token",
        authorize_path: "/oauth/authorize",
        access_token_path: "/oauth/access_token",
      }

## Instance Attribute Summary collapse

- #base_url ⇒ Object

  Returns the value of attribute base_url.

## Instance Method Summary collapse

- #access_token_path ⇒ Object
- #access_token_url ⇒ Object
- #authorize_path ⇒ Object
- #authorize_url ⇒ Object
- #create_consumer ⇒ Object

  mainly for testing purposes.

- #generate_consumer_credentials(_params = {}) ⇒ Object
- #generate_credentials ⇒ Object
- #initialize(base_url, paths = {}) ⇒ Server constructor

  Create a new server instance.

- #request_token_path ⇒ Object
- #request_token_url ⇒ Object

### Methods included from Helper

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

## Constructor Details

### #initialize(base_url, paths = {}) ⇒ `Server`

Create a new server instance

    20
    21
    22
    23
    # File 'lib/oauth/server.rb', line 20

    def initialize(base_url, paths = {})
      @base_url = base_url
      @paths = @@server_paths.merge(paths)
    end

## Instance Attribute Details

### #base_url ⇒ `Object`

Returns the value of attribute base_url.

    11
    12
    13
    # File 'lib/oauth/server.rb', line 11

    def base_url
      @base_url
    end

## Instance Method Details

### #access_token_path ⇒ `Object`

    64
    65
    66
    # File 'lib/oauth/server.rb', line 64

    def access_token_path
      @paths[:access_token_path]
    end

### #access_token_url ⇒ `Object`

    68
    69
    70
    # File 'lib/oauth/server.rb', line 68

    def access_token_url
      base_url + access_token_path
    end

### #authorize_path ⇒ `Object`

    56
    57
    58
    # File 'lib/oauth/server.rb', line 56

    def authorize_path
      @paths[:authorize_path]
    end

### #authorize_url ⇒ `Object`

    60
    61
    62
    # File 'lib/oauth/server.rb', line 60

    def authorize_url
      base_url + authorize_path
    end

### #create_consumer ⇒ `Object`

mainly for testing purposes

    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    # File 'lib/oauth/server.rb', line 34

    def create_consumer
      creds = generate_credentials
      Consumer.new(
        creds[0],
        creds[1],
        {
          site: base_url,
          request_token_path: request_token_path,
          authorize_path: authorize_path,
          access_token_path: access_token_path,
        },
      )
    end

### #generate_consumer_credentials(_params = {}) ⇒ `Object`

    29
    30
    31
    # File 'lib/oauth/server.rb', line 29

    def generate_consumer_credentials(_params = {})
      Consumer.new(*generate_credentials)
    end

### #generate_credentials ⇒ `Object`

    25
    26
    27
    # File 'lib/oauth/server.rb', line 25

    def generate_credentials
      [generate_key(16), generate_key]
    end

### #request_token_path ⇒ `Object`

    48
    49
    50
    # File 'lib/oauth/server.rb', line 48

    def request_token_path
      @paths[:request_token_path]
    end

### #request_token_url ⇒ `Object`

    52
    53
    54
    # File 'lib/oauth/server.rb', line 52

    def request_token_url
      base_url + request_token_path
    end