问题
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.
meteor add accounts-twitter
andmeteor add accounts-ui
- Added
{{> loginButtons}}
to HTML. - In Cloud9 terminal
meteor --port $IP:$PORT
- Followed the on screen instructions on apps.twitter.com
- Set website
abc-matthewcanty.c9.io/
- Set callback URL
http://0.0.0.0:8080/_oauth/twitter
- this is what I am told to do. - Copied in
API Key
andAPI Secret
- 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:
- Website: https://abc-matthewcanty.c9.io/
- Callback URL: https://abc-matthewcanty.c9.io/ also tried this with _oauth/twitter?close
When I click on the button I don't know how to stop it from going to http://0.0.0.0:8080/etc
回答1:
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 theROOT_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.
回答2:
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
来源:https://stackoverflow.com/questions/31503844/meteor-accounts-twitter-unable-to-get-working