I'm following the instructions from Carin Meier's How I Start post and having an issue with posting to twitter (like her example) from Heroku. Note that my app does not have a web component, just a worker component.
Testing on my desktop, I'm able to post to twitter and gist.github.com.
But, on Heroku, I always get Exception in thread "main" java.lang.Exception: Twitter responded to request with error 32: Could not authenticate you.
I am able to post to gist.github.com, so it appears to be a twitter-only issue.
I have used heroku run lein repl
to confirm that my creds look just fine:
(reset! my-twitter-creds (tw-oauth/make-oauth-creds
(env :app-consumer-key)
(env :app-consumer-secret)
(env :user-access-token)
(env :user-access-secret)))
but a call to:
(tw/statuses-user-timeline :oauth-creds @my-twitter-creds
:params {:count 1 :screen-name "myname"})
Always gives the error 32.
All the code I've created for this is available to browse here: https://github.com/rogerallen/tweegeemee/blob/master/src/tweegeemee/core.clj
My current suspicion is that there is some requirement on Heroku for a twitter Oauth callback URL. But, since my app does not have a web-worker, I don't want to have to add this (and it isn't mentioned in the post).
Can anyone help me get this working?
From what you described, if you can post to twitter using lein run locally with your environment variables - then the only difference should be the environment variables that heroku is using.
Maybe check with
heroku config
or even put some more logging in an watch in the heroku logs to see what it is calling it with.