问题
Yesterday, I discovered Firebase and started to use it. I deployed an edited version (I just changed the CSS) of the chat app provided by Firebase, Everything went OK until I added Twitter Logging option. I couldn't authenticate my app with Twitter even though I followed these instructions and I activated "Sign in with Twitter" from Twitter Application Management Panel.
This is the code I'm using in my chat app to log in (anything else is related to Twitter logging in my code):
// instatiate the FirebaseSimpleLogin and monitor the user's auth state
var chatRef = new Firebase('https://ranchat.firebaseIO.com');
var auth = new FirebaseSimpleLogin(chatRef, function(error, user) {
if (error) {
// an error occurred while attempting login
alert(error);
} else if (user) {
// user authenticated with Firebase
alert('Welcome' + user.username);
} else {
// user is logged out
}
});
// attempt to log the user in with your preferred authentication provider
$('#twlog').click(function(){
auth.login('twitter', {
RememberMe: true
});
});
These are the Firebase Rules I'm using
{
"rules": {
".read": true,
"$comment": {
".write": "!data.exists() && newData.child('twitter_id').val() == auth.id"
}
}
}
And this is what happens after press Twitter Log button in my app
Error: FirebaseSimpleLogin: An unknown error occurred
Honesly, I don't know why it happening. Would you give a hand?
回答1:
I found the solution thanks to @RobDiMarco.
The error was occuring due to an incorrect copy of Twitter API ID and API Secret into my Firebase Forge. I just needed to copy these and then paste it here.
回答2:
The terminology is very confusing in Firebase Simple Login documentation. Firebase requires three things:
- Twitter App ID (used in the client call), which is the "API key" from API keys tab in your Twitter application settings page
- Twitter Consumer Key (entered into Firebase Forge), which is also the "API key"
- Twitter Consumer Secret (entered into Firebase Forge), which is the "API secret" from the same tab
来源:https://stackoverflow.com/questions/22104121/i-receive-an-firebasesimplelogin-an-unknown-error-occurred-in-firebase-when-i