1

I want to make request through curl or other stuff (Net::HTTP.get). How can I set request.env['omniauth.auth'] when I make request? What is request.env in general?

For example, take a look at https://github.com/intridea/omniauth#integrating-omniauth-into-your-application

class SessionsController < ApplicationController
  def create
    @user = User.find_or_create_from_auth_hash(auth_hash)
    self.current_user = @user
    redirect_to '/'
  end

  protected

  def auth_hash
    request.env['omniauth.auth']
  end
end

I don't know how to set request.env['omniauth.auth'] when I do curl

Andrey Moroz
  • 293
  • 1
  • 3
  • 15
  • 3
    Normally `request.env` pertains to requests being *received*, not being made. – tadman May 10 '16 at 18:52
  • I want to make request with params and when my app receive it, request.env['omniauth.auth'] should be equal to those params. My app check request params request.env['omniauth.auth'], but I have no idea how to manage them – Andrey Moroz May 10 '16 at 18:56
  • 2
    I have no idea what you're doing. Can you include some code that demonstrates what you're attempting? – tadman May 10 '16 at 18:58
  • Must you use something like curl that's outside Ruby, or can rack-test accomplish this? https://github.com/brynary/rack-test – Jim Van Fleet May 10 '16 at 20:36
  • Okay, take a look at https://github.com/intridea/omniauth#integrating-omniauth-into-your-application def auth_hash request.env['omniauth.auth'] end I don't know how to set this param when I do curl – Andrey Moroz May 11 '16 at 08:14

2 Answers2

0

You really need stuff for manage ENV global vars. And use it like ENV['omniauth_facebook']

Use dotenv gem, and it is good in production too.

Mike Belyakov
  • 1,355
  • 1
  • 13
  • 24
0

The HTTP headers should show up in the request.env with HTTP_ prefixed.

With httpie, this is as simple as

http scheme://your-url.tld/path/to/endpoint Header:Something

You should be able to access this with request.env['HTTP_Header']

Igbanam
  • 5,904
  • 5
  • 44
  • 68