0

I am using Firebase in my Google Chrome App. Since Chrome Apps do not have a domain and a callback url, I need to authorize with the Token and not the popup.

I am having problems getting authWithOAuthToken to work, even in the browser.

In this code example the first call to authWithOAuthPopup works, I get the popupData which includes github account info and my token. The issue is that the second call to authWithOAuthToken is not working. I get an error

     db.authWithOAuthPopup("github", function(error, popupData) {
        if (error) {
            console.log("Login Failed!", error);
        } else {

            console.log("Authenticated successfully with payload: ", popupData);
            console.log("Now attempting to Authorize with Token...");


            db.authWithOAuthToken("github", popupData.token, function (err, tokenData) {
                if (err) {
                    console.log("Login Failed!", err);
                } else {
                    console.log("Authenticated successfully", tokenData);
                }
            });
        }
    });

My console output shows the first call working, and the second call failing:

  bundle.js:20498 Authenticated successfully with payload:  Object  
  Now attempting to Authorize with Token...
  Login Failed! Error: Invalid authentication credentials provided.(…)

How can I get authWithOAuthToken to work?

4

1 回答 1

0

The token you would pass into authWithOAuthToken() needs to be a GitHub OAuth token, not a Firebase one. Thus the correct token would be popupData.github.accessToken rather than popupData.token. More can be read on the token contents here.

于 2015-10-19T23:45:27.490 回答