alarner / perk

A well documented set of tools for building node web applications.
http://perkframework.com
MIT License
181 stars 31 forks source link

OAuth Support: Dropbox #12

Open alarner opened 8 years ago

addykim commented 7 years ago

I think I'd like to try tackling this. Could you give some information about what this issue is aiming to do?

alarner commented 7 years ago

Hey @addykim I'm glad you're interested in tackling this issue! Here's a little bit more info on what's needed:

Perk's user authentication system is built on top of Passport, which has many different adapters for login using third party providers. The problem is that once a user authenticates with a third party provider (eg. Facebook or Twitter) the data that is returned by that provider is not in a standardized format. To deal with this problem Perk has adapters to take the data that the provider returns and standardize it. There are already four providers that do this for Facebook, GitHub, Google and Trello. This issue would involve creating a fifth to handle the Data returned by Dropbox.

To get started you will want to:

  1. Create developer account with Dropbox and register API keys. They should give you a client id and a client secret or something along those lines.
  2. Add a new section to config/auth.js that mimics one of the existing providers (don't use Trello, theirs is a bit weird, but any of the others are fine). Fill in your api keys there.
  3. Create a new adapter for dropbox in the adapters directory. The adapter is mostly a function that takes four arguments (accessToken, refreshToken, profile, and a callback). You will need to inspect the structure and contents of the profile argument and call the callback argument with an object that contains the dropbox user id, first name, last name and email of the user who logged in. This info should be available within the profile object. I would start by console.log'ing the contents of profile to see what it looks like. You can also model your adapter after one of the existing ones (again avoid the Trello one, but the others are fair game).
  4. To test it out you can boot up the perk server using npm run dev and then go to http://localhost:3000/auth/dropbox/login to initiate the login flow. Upon successfully logging in your adapter should be automatically called with the profile information.

If you run into any snags I'm happy to help out.

iifeoluwa commented 7 years ago

Is this still available? I'd like to take this if no one is working on it.

alarner commented 7 years ago

@addykim are you still working on this? If not do you mind if @iifeoluwa takes it over?

addykim commented 7 years ago

I got caught up in other things and did not make progress. @iifeoluwa go for it.