Jump to content

Using OAuth2


thefirstofthe300

Recommended Posts

thefirstofthe300

I am attempting to get a plugin working (Luke probably knows which one ;) ) and I am wondering how to get OAuth working. This is my first time even attempting to work with OAuth so I am very unfamiliar with the workflow. However, based on my understanding of what I have read, the workflow goes something like this:

  1. I post to the OAuth URL with the client_id and a pop up with the sign in page for the service pops up.
  2. The user grants permission for the app to access the user's account.
  3. The app receives an authorization code and redirects to the value of the redirect URI.
  4. The app requests an auth token from the OAuth server using the client_id, client_secret, and authorization code.
  5. If authorization is successful, the app receives an auth token and a refresh token which it then uses to communicate with the server.
  6. When the auth token expires, the app uses the refresh token to get a valid auth token.

Due to the nature of OAuth, I really haven't found a way to simply login with a username and password that doesn't revoke the ability to use a refresh token so that is out of the question (due to the nature of what I am trying to do).

 

If I am incorrect in any of the above points, please correct me. :)

My question is this: will the OAuth popup work with the plugin configuration? I imagine it would but I don't want to get into this, have it not work, and be chasing my tail attempting to figure out why if the problem is with the server itself.

Link to comment
Share on other sites

hamstercat

Yeah it does work, OAuth2 is not the simplest thing to understand but once you get the hang of it it's fine. You can look at my Google Drive one if you need inspiration, I'm using OAuth there as well in the config page.

Link to comment
Share on other sites

thefirstofthe300

Thanks hamstercat. That was all I needed to know. ;)

 

Any idea when your Drive plugin is getting published? I personally use Drive and would like to see how it works (auth and all).

Link to comment
Share on other sites

i gave him a change to make, once that's done i think it's going to be about ready to go

  • Like 1
Link to comment
Share on other sites

thefirstofthe300

Quick question, what is your redirect url configured to be?

Link to comment
Share on other sites

hamstercat

It must be the config page, so I'm using javascript to find the current URL before doing the redirect. Then, you can use the code you receive and make appropriate calls to find the access token and refresh token and save them in the config.

Edited by hamstercat
Link to comment
Share on other sites

thefirstofthe300

Regarding the change to the config page, is there a standard format that you want to use for it?

Link to comment
Share on other sites

hamstercat

Using the folder sync plugin as inspiration, the Google Drive now looks like this (not yet comitted):

 

550979003e060_config.jpg

 

There is a place at the top for plugin-wide config, and then the user can add connections to Google Drive with a name and the users who are allowed to use it.

  • Like 1
Link to comment
Share on other sites

  • 2 years later...
Untoten

Using the folder sync plugin as inspiration, the Google Drive now looks like this (not yet comitted):

 

550979003e060_config.jpg

 

There is a place at the top for plugin-wide config, and then the user can add connections to Google Drive with a name and the users who are allowed to use it.

Did you ever make further progress on this?  I am beginning to lose faith that LDAP or SSO will ever be added so I am trying anything.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...