Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

access user profile via oauth tokens passport.js

I have been using passport.js. It works and I am able to get the oauth_token and Verifier easily from APIs.

In passport.js each API has a strategy which basically decide how to communicate with that API server. At the end a callback to get returned user profile.

But I saw no way to use oauth_token to get the profile myself. Its a one time shot at the end of Oauth authentication to save data in session or db.

Is there any way I can use my oauth_token to directly access the user profile any time usingpassport methods.

In prototype I saw userProfile function which does what I need but its a private method somehow. I don't know how to use it

Update 1

I have been scavenging the git repo for passport.js , I come to know they use the "node-oauth" to manage calls to the API servers. This is available in any strategies _oauth.

But I am not aware what calls to make to get resource token. Also I have to initiate all API calls in callbacks step by step to imitate the token access calls. Is there any standard way to do this.

like image 212
Sushant Avatar asked Dec 06 '25 03:12

Sushant


1 Answers

Without digging into the code (but having used Passport before) I'm assuming that the oauth_token is being stored with the user data in your database. You may have to access your database models directly in order to get the token, then you can use it with the provider APIs to get access to the information you need.

like image 82
robertjd Avatar answered Dec 08 '25 17:12

robertjd