class Her::Middleware::OAuthProviderHeader
Public Instance Methods
add_header(headers)
click to toggle source
# File lib/her/middleware/o_auth_provider_header.rb, line 5 def add_header(headers) headers.merge! Authorization: "Bearer #{refresh_token['access_token']}" end
call(env)
click to toggle source
# File lib/her/middleware/o_auth_provider_header.rb, line 45 def call(env) add_header(env[:request_headers]) @app.call(env) end
password()
click to toggle source
# File lib/her/middleware/o_auth_provider_header.rb, line 39 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 24 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 9 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 15 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 35 def token_url 'https://api.parasut.com/oauth/token' end