class Her::Middleware::OAuthProviderHeader
Public Class Methods
add_header(headers)
click to toggle source
# File lib/her/middleware/o_auth_provider_header.rb, line 8 def add_header(headers) headers.merge! Authorization: "Bearer #{refresh_token['access_token']}" end
password()
click to toggle source
# File lib/her/middleware/o_auth_provider_header.rb, line 42 def password uri = URI("#{token_url}?#{URI.encode_www_form(password_params)}") res = Net::HTTP.post_form(uri, {}) JSON.parse(res.body) end
password_params()
click to toggle source
# File lib/her/middleware/o_auth_provider_header.rb, line 27 def password_params { client_id: Parasut.options.client_id, client_secret: Parasut.options.client_secret, username: Parasut.options.username, password: Parasut.options.password, grant_type: 'password', redirect_uri: 'urn:ietf:wg:oauth:2.0:oob' } end
refresh_token()
click to toggle source
# File lib/her/middleware/o_auth_provider_header.rb, line 12 def refresh_token uri = URI("#{token_url}?#{URI.encode_www_form(refresh_token_params)}") res = Net::HTTP.post_form(uri, {}) JSON.parse(res.body) end
refresh_token_params()
click to toggle source
# File lib/her/middleware/o_auth_provider_header.rb, line 18 def refresh_token_params { client_id: Parasut.options.client_id, client_secret: Parasut.options.client_secret, grant_type: 'refresh_token', refresh_token: password['refresh_token'] } end
token_url()
click to toggle source
# File lib/her/middleware/o_auth_provider_header.rb, line 38 def token_url "#{Parasut.options.api_base_url}/oauth/token" end
Public Instance Methods
call(env)
click to toggle source
end static
# File lib/her/middleware/o_auth_provider_header.rb, line 53 def call(env) Her::Middleware::OAuthProviderHeader.add_header(env[:request_headers]) @app.call(env) end