Ad
Is It Possible To Access A User's Twitter Access Token And Secret With The Firebase Javascript SDK?
I'm using the Firebase Javascript SDK and currently have users able to sign up and into, as well as link from settings, their Twitter accounts. I'd like to present users with an option to share new posts to Twitter without having them have to do it manually.
Is it possible to grab a user's access token and secret so I can make a request like this to Twitter?
Currently I'm calling sign in with this code:
doSignInWithTwitter = () =>
this.auth.signInWithPopup(this.twitterProvider);
Ad
Answer
Yes. It is in the result of signInWithPopup
:
firebase.auth().signInWithPopup(provider).then(function(result) {
// This gives you a the Twitter OAuth 1.0 Access Token and Secret.
// You can use these server side with your app's credentials to access the Twitter API.
var token = result.credential.accessToken;
var secret = result.credential.secret;
// The signed-in user info.
var user = result.user;
// ...
}).catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// The email of the user's account used.
var email = error.email;
// The firebase.auth.AuthCredential type that was used.
var credential = error.credential;
// ...
});
Example taken directly from Firebase docs.
Ad
source: stackoverflow.com
Related Questions
- → How to update data attribute on Ajax complete
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → Octobercms Component Unique id (Twig & Javascript)
- → Passing a JS var from AJAX response to Twig
- → Laravel {!! Form::open() !!} doesn't work within AngularJS
- → DropzoneJS & Laravel - Output form validation errors
- → Import statement and Babel
- → Uncaught TypeError: Cannot read property '__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined
- → React-router: Passing props to children
- → ListView.DataSource looping data for React Native
- → Can't test submit handler in React component
- → React + Flux - How to avoid global variable
- → Webpack, React & Babel, not rendering DOM
Ad