hainproject / hain

An 'alt+space' launcher for Windows, built with Electron
http://hainproject.github.io/hain/
MIT License
3.2k stars 157 forks source link

Login to 3rd party service through OAuth2 #149

Open likerRr opened 8 years ago

likerRr commented 8 years ago

Hi!

I'm thinking about integration one service to the hain, but it requires user to input login/pass and grant access rights to the application. Is it possible with the hain to display a 3rd party's auth form for login/pass input? If yes what should I specify as redirect_uri for OAuth process? :)

appetizermonster commented 8 years ago

Can I know the service that you integrate? I may find the way to solve it.

likerRr commented 8 years ago

@appetizermonster https://getpocket.com

appetizermonster commented 8 years ago

I read the docs on https://getpocket.com/developer/docs/. Currently, There is no official way to support it. It takes very long time to fully support it. but I think you can achieve this by using web server framework (like expressjs) to simulate callback server.

likerRr commented 8 years ago

Site, I can, but I also have to show login form to user. Even if I open a browser for it I will not be able to get access token back to hain 😞 Some workaround can be achieved by saving access token on my server and then request it from hain, but I'm not sure if it worth.

Anyway, thank you

appetizermonster commented 8 years ago

I think i should mention that you can operate local webserver in your plugin because hain plugin is being executed in normal nodejs process

likerRr commented 8 years ago

You right, but still no way to open web page in child process and get data from it. Do you plan or even think about such ability?

likerRr commented 8 years ago

I have some ideas, will try to implement and will share results here

ewnd9 commented 8 years ago

@likerRr you could open a webpage with opn

const opn = require('opn');
opn('http://localhost:3000/');
likerRr commented 8 years ago

@ewnd9 yeah, I've already done so, the only thing is left is to send data from that page to Hain, but it should be easy because we have access to node server. So, this way OAuth2 authentication can be organized in Hain. But should think about usability.

likerRr commented 8 years ago

Hi, @appetizermonster . I was busy a lot and haven't reported results of oauth implementation. Actually I did it! :) And it works fine. Unfortunately I haven't opened the code for now, because during the plugin development I started making a little framework for Hain to build plugins.

I would appreciate if you take a look at the Kain. Now it's in very pre version, but already has extended wiki to understand what it provides. May be you will like it and will mention about Kain in Hain's wiki.

Anyway, after I finish implementing Kain to my plugin with oauth support I will post it here to have an example for other people. Hope it will be done in 2 weeks, because tomorrow I go on vacation.

appetizermonster commented 8 years ago

@likerRr I'm very impressed for your Kain, Okay I'll mention it this wiki or docs!

likerRr commented 8 years ago

@appetizermonster thanks! I'll continue update docs and will provide some examples, because now it's not clear how it works.