I made a website that uses the Twitter Ruby gem. On local host, I can get the Twitter gem to work fine, but when I deployed it to Heroku, I’m having trouble signing in via Twitter.
Heroku provides instructions (using Amazon S3 variables) about adding the CONSUMER_KEY and the CONSUMER SECRET
$ cd myapp
$ heroku config:add S3_KEY=some_key_here S3_SECRET=some_secret_here
I did that.
Then when I go to test sign in, I get this in the url. This url is the same as when (on a local host) I forget to add CONSUMER_KEY etc, so I’m thinking that I didn’t set up the CONSUMER_KEY and CONSUMER_SECRET properly on Heroku…

Heroku provides further details about setting up a file in config/initalizers to read the variables at runtime, but I think the Github project I forked and then adapted already has this set up https://github.com/sferik/sign-in-with-twitter/blob/master/config/initializers/omniauth.rb so I’m not sure what’s going on.
Set up your code to read the vars at runtime in config/initializers/s3.rb:
AWS::S3::Base.establish_connection!(
:access_key_id => ENV['S3_KEY'],
:secret_access_key => ENV['S3_SECRET']
)
UPDATE
error message in Heroku logs when I try to signin via Twitter. Note, i can sign in via local host.
2012-01-02T20:01:43+00:00 app[web.1]:
2012-01-02T20:01:43+00:00 app[web.1]: Started GET "/auth/twitter?utf8=%E2%9C%93" for 64.46.7.250 at 2012-01-02 20:01:43 +0000
2012-01-02T20:01:44+00:00 app[web.1]:
2012-01-02T20:01:44+00:00 app[web.1]: OAuth::Unauthorized (401 Unauthorized):
2012-01-02T20:01:44+00:00 app[web.1]:
This could be one of two things.
Either your keys are not setup correctly, or the route that the Twitter OAuth callback comes back to is not correct (in that it is not processing correctly).
The easiest to check is your Heroku config:
This should show
CONSUMER_KEYandCONSUMER_SECRET(I’m assuming your use ofS3_KEYandS3_SECRETabove are placeholders)Should this config be correct, and it still doesn’t work you’ll need to dig into the processing of the request that comes back to your application. It seems to be processing /auth/twitter as it should, but something it not correct within this step.