2

I've been having a go at Meteor. I want to use OAuth to authenticate users on my site as I do not want to implement the login features myself.

At the moment my website is very simple. A counter, where you click a button the counter increases by one. The idea being when a user goes to another machine and logs in their count is persisted.

I have followed the steps on meteor.com/accounts.

  1. meteor add accounts-twitter and meteor add accounts-ui
  2. Added {{> loginButtons}} to HTML.
  3. In Cloud9 terminal meteor --port $IP:$PORT
  4. Followed the on screen instructions on apps.twitter.com
  5. Set website abc-matthewcanty.c9.io/
  6. Set callback URL http://0.0.0.0:8080/_oauth/twitter - this is what I am told to do.
  7. Copied in API Key and API Secret
  8. Chose pop-up based authentication and pressed save

Now when I click Sign in with Twitter I get a pop up which says:

This webpage is not available

ERR_ADDRESS_INVALID

The address of the popup is as follows:

0.0.0.0:8080/_oauth/twitter/?requestTokenAndRedirect=true&state=eyJsb2dpblN......

Note that using abc-matthewcanty.c9.io/ as the Callback URL makes not difference.

Is this because I am using Cloud9 IDE and there is a little more tinkering that I have to do?

The Meteor documentation provides no further steps. Probably assumes knowledge of OAuth as a prerequisite but does not state as such.

Edit

I visited the site suggested by @tomas-hromnik below:

http://www.servicepro.wiki/wiki/1171/cloud9-twitter-account-integration-for-sign-up

And updated the app settings in apps.twitter.com:

When I click on the button I don't know how to stop it from going to http://0.0.0.0:8080/etc

Twitter OAuth naviating to 0.0.0.0

Matt Canty
  • 2,395
  • 5
  • 35
  • 50
  • Is your workspace / application server access public? You can check that by clicking on 'Share' and seeing whether 'Public' is checked next to 'Application' – Mutahhir Jul 20 '15 at 08:26
  • Sorry still nothing... Updated addresses to the public facing application URLs. Tried regenerating app key & secret and reconfiguring. – Matt Canty Jul 20 '15 at 08:39
  • If I take the URL that is in the popup window and add my website in place of the IP:PORT then the authentication completes. – Matt Canty Jul 20 '15 at 08:40
  • 1
    Hmm, so, this is just a guess, but its possible that meteor package hard-codes 0.0.0.0:8080 in the callback url and twitter respects it. This [answer](http://stackoverflow.com/questions/19363677/meteor-0-6-6-1-login-with-twitter-auth-callback-issue) maybe helps, set the ROOT_URL env variable to your workspace url. – Mutahhir Jul 20 '15 at 09:05
  • :-D Works like a charm! – Matt Canty Jul 20 '15 at 09:13
  • 1
    Awesome! :) I'll post that as an answer to help others – Mutahhir Jul 20 '15 at 09:17
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/83769/discussion-between-bassbytesbikes-and-mutahhir). – Matt Canty Jul 20 '15 at 15:00

2 Answers2

5

Here are the steps you need to do to make Twitter auth work with Meteor on Cloud9:

  • Make sure your application is Public, not private. You can do that by clicking on 'Share', and checking Public next to 'Application' within your Cloud9 workspace
  • Make sure you set the twitter callback as https://<workspace-name>-<username>.c9users.io
  • Since Meteor twitter auth package defaults to using 0.0.0.0:8080 (the IP:PORT you start it with) as the callback host, so you need to add the ROOT_URL environment variable. If you're using a Cloud9 runner, you can add environment variables by clicking on the 'ENV' button on the run panel and adding it. Set ROOT_URL to your application's external URL. Otherwise you can just do it within the terminal by typing in: $ export ROOT_URL='https://<workspace-name>-<username>.c9users.io/'

Note: Please note that by default Meteor starts at port 3000, but you need to set the port to 8080 in order to make it work.

Mutahhir
  • 3,812
  • 3
  • 21
  • 26
0

I don't think the address 0.0.0.0:8080 is correct. Meteor runs on port 3000 by default and his address is localhost, so the callback URL should be http://127.0.0.1:3000/_oauth/twitter?close

Read more about using Twitter login with Meteor in this tutorial: http://meteor.hromnik.com/blog/login-with-facebook-twitter-and-google-in-meteor

EDIT: For production usage use your production URL:

http://abc.matthewcanty.c9.io/_oauth/twitter?close

Here are steps for creating Twitter account integration on Cloud9: http://www.servicepro.wiki/wiki/1171/cloud9-twitter-account-integration-for-sign-up

Tomas Hromnik
  • 2,190
  • 13
  • 21
  • I'm afraid that is not possible in Cloud9. The terminal requests that you execute `meteor` with the argument `--port $IP:$PORT`. Which sets you up on 0.0.0.0 port 8080. – Matt Canty Jul 19 '15 at 21:22
  • To add to that, I tried running Meteor without any arguments and it isn't possible to reach the page in Cloud9 - ie, by browsing to localhost:3000 in the embedded browser. – Matt Canty Jul 19 '15 at 21:25
  • If you add production URL and allow the twitter app to be used to sign in with Twitter, it must work. I have updated the answer. – Tomas Hromnik Jul 20 '15 at 07:31
  • Updated my question with further information. Please note it should have been *abc-* not *abc.* – Matt Canty Jul 20 '15 at 08:14