Module: Stagehand::Client::OAuth

Included in:
Stagehand::Client
Defined in:
lib/stagehand/client/oauth.rb

Overview

Methods for OAuth 2.0 authentication

Instance Method Summary collapse

Instance Method Details

#access_tokenObject



22
23
24
# File 'lib/stagehand/client/oauth.rb', line 22

def access_token
  request.env['rack.session'][:access_token]
end

#access_token_urlObject



10
11
12
# File 'lib/stagehand/client/oauth.rb', line 10

def access_token_url
  Stagehand.config.resource_host + "/oauth/access_token"
end

#authorize_urlObject

URL used for initial OAuth login and authorization



6
7
8
# File 'lib/stagehand/client/oauth.rb', line 6

def authorize_url
  Stagehand.config.resource_host + "/oauth/authorize?client_id=#{Stagehand.config.client_id}&client_secret=#{Stagehand.config.client_secret}&redirect_uri=#{Stagehand.config.client_host}/callback"
end

#get_with_access_token(path, params) ⇒ Object



26
27
28
29
# File 'lib/stagehand/client/oauth.rb', line 26

def get_with_access_token(path, params)
  params[:oauth_token] = access_token
  HTTParty.get(Stagehand.config.resource_host + path, query: params)
end

#logout_urlObject



18
19
20
# File 'lib/stagehand/client/oauth.rb', line 18

def logout_url
  Stagehand.config.resource_host + "/logout?redirect_uri=#{Stagehand.config.client_host}"
end

#redirect_uriObject



14
15
16
# File 'lib/stagehand/client/oauth.rb', line 14

def redirect_uri
  Stagehand.config.client_host + "/callback"
end