Class: Stormpath::Rails::Oauth2::CreateController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/stormpath/rails/oauth2/create_controller.rb

Constant Summary collapse

UnsupportedGrantType =
Class.new(StandardError)

Instance Method Summary collapse

Instance Method Details

#callObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/stormpath/rails/oauth2/create_controller.rb', line 7

def call
  response.headers['Cache-Control'] = 'no-store'
  response.headers['Pragma'] = 'no-cache'

  case grant_type
  when 'client_credentials'
    handle_client_credentials_grant
  when 'password'
    handle_password_grant
  when 'refresh_token'
    handle_refresh_token_grant
  else
    raise UnsupportedGrantType if grant_type.present?
    render json: { error: :invalid_request }, status: 400
  end
rescue UnsupportedGrantType
  render json: { error: :unsupported_grant_type }, status: 400
end