Comments (8)
I just tried creating a new Tumblr application and generate new consumer key and consumer secret. Works fine here.
Also, note that I am not using Tumblr strategy for authentication. The whole reason behind:
passport.use('tumblr', new OAuthStrategy({
requestTokenURL: 'http://www.tumblr.com/oauth/request_token',
accessTokenURL: 'http://www.tumblr.com/oauth/access_token',
userAuthorizationURL: 'http://www.tumblr.com/oauth/authorize',
consumerKey: secrets.tumblr.consumerKey,
consumerSecret: secrets.tumblr.consumerSecret,
callbackURL: secrets.tumblr.callbackURL,
passReqToCallback: true
},
function(req, token, tokenSecret, profile, done) {
User.findById(req.user._id, function(err, user) {
user.tokens.push({ kind: 'tumblr', accessToken: token, tokenSecret: tokenSecret });
user.save(function(err) {
done(err, user);
});
});
}
));
is so obtain accessToken and tokenSecret so I can use it with the Tumblr API library.
And since you didn't provide a full error stack I assume 500 TypeError: Cannot read property '_id' of undefined
refers to this line:
User.findById(req.user._id, function(err, user) {
I am surprised that req.user is undefined. Before you can see Tumblr page it will ask you to first sign-in, at which point req.user
should be defined.
from hackathon-starter.
@brianyang For passport-tumblr, of course you will get oauth_consumer_key not recognized
if you're just trying to run their examples without inputting your own consumerKey and consumerSecret.
Did you follow Tubmlr instructions on Obtaining API Keys in README?
from hackathon-starter.
@sahat what's the difference between authenticating with tumblr, vs fb, twitter, instagram? i'm wondering why the login view doesn't show that the user is logged in with tumblr. i see the key and secret coming back, that's all that's needed to authenticate requests from the tumblr API. i was just wondering what's the difference between tumblr passport and the other passports i've tried, fb, twitter, instagram, fitbit. with these other ones it shows 'logout' after authorizing the app.
do you know why this is?
from hackathon-starter.
I am using passport plugins for Facebook, Twitter, Google, GitHub to do authentication. In other words you can use those providers to sign in, create account, logout. In addition to authentication you can also access those APIs, because when you login you also get an access token.
Tumblr, Venmo, Foursquare on the other hand are not used for authentication, only for API requests.
To be honest you can use anything for authentication, but most people won’t need more than 3 - Twitter, Google, Facebook. Imagine if I made every OAuth provider to be used for authentication; they wouldn’t fit on the login screen!
I use passport-facebook, passport-twitter, passport-google-oauth, passport-github, passport-whatever, when I know I will be using it for user authentication. I use plain passport-oauth
when I need to obtain accessToken and I don’t plan on using that service for user authentication.
If you want to sign in with Tumblr or Instagram find passport-tumblr and passport-instagram. You might be able to use custom-defined Tumblr strategy via passport-oauth, but I am not exactly sure how that would work.
// Using it for sign-in
app.get('/auth/facebook', passport.authenticate('facebook', { scope: ['email', 'user_location'] }));
app.get('/auth/facebook/callback', passport.authenticate('facebook', { successRedirect: '/', failureRedirect: '/login' }));
// Not used for sign-in, only for obtaining an access_token to get user’s checkins.
app.get('/auth/foursquare', passport.authorize('foursquare'));
app.get('/auth/foursquare/callback', passport.authorize('foursquare', { failureRedirect: '/api' }), function(req, res) {
res.redirect('/api/foursquare');
});
from hackathon-starter.
@brianyang were you able to resolve your issue?
from hackathon-starter.
@sahat, app.js authorizes with tumblr:
app.get('/auth/tumblr', passport.authorize('tumblr'));
then it invokes this function:
User.findById(req.user._id, function(err, user) {
user.tokens.push({ kind: 'tumblr', accessToken: token, tokenSecret: tokenSecret });
...
});
what is findById() doing here? after authorizing the Tumblr app, req.user is undefined. this will always return undefined and the tokens will never be saved. what is the intended interaction?
should we save both of these tokens and use these to authorize the API requests?
Thanks,
from hackathon-starter.
@brianyang Yes you need both tokens. Regarding req.user being undefined is because user is not logged in. Being logged in is a pre-requisite for using Tumblr API or any other API that uses accessToken. At least it is in Hackathon Starter.
from hackathon-starter.
awesome, thanks!
from hackathon-starter.
Related Issues (20)
- URL is not working HOT 3
- Error building docker image HOT 7
- Learn node
- Can we use nodemon by default? HOT 2
- Brave browser blocks the cookieconsent HOT 1
- Node 20 HOT 4
- mongoose connection HOT 3
- Add JWT Authentication Support
- Implement Passport Serialization and Deserialization HOT 5
- Implement support for Novu as a notification infrastructure HOT 1
- Will make navbar remain on top on scrolling HOT 5
- Uniform text colour under "API Examples" tab HOT 11
- Creating seperate database config file HOT 2
- Destroying the cookies after logout of user HOT 2
- Adding OAUTH 2.0 HOT 3
- Refactoring config/passport.js HOT 5
- Mongo Running, Connection Error
- Asked assistant HOT 1
- Migrate from namespaced javaScript to Modular javaScript
- Encountering an issue with the script execution in Windows environment. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hackathon-starter.