Need tips for non-web OAuth workflow

16 views
Skip to first unread message

Saimadhav Heblikar

unread,
Nov 27, 2014, 1:33:54 PM11/27/14
to pes-ope...@googlegroups.com
Hi,

What I am trying to do: A command line application which needs to
authorize itself with a 3rd party API. The user should enter their
credentials(user name and password) only once. The application should
authorize itself, create OAuth tokens with requisite scopes(the API in
question supports this), and retrieve the access token for local
storage on the clients machine.

The way the API in question works(and has probably been designed for)
is it calls back(read as: redirects the web browser) to a predefined
URL with the access token as a request parameter. All this is fine.

My problem is that since the application is a command line based, how
do I solve this issue? Are there any known paradigms of going about
this? I really don't want to go down the route of using Selenium etc.

I can modify server side code as a last resort, but *only* as a last resort.

If my question is bit confusing, let me know and I shall provide more details.



--
Regards
Saimadhav Heblikar

Alok Shankar

unread,
Nov 27, 2014, 2:35:30 PM11/27/14
to pes-ope...@googlegroups.com
Check out oacurl. Basically, you create a config file, say oauth.conf
consumerKey=CONSUMER_KEY
consumerSecret=CONSUMER_SECRET
requestTokenUrl=https://service/oauth/request_token
userAuthorizationUrl=https://service/oauth/authorize
accessTokenUrl=https://localhost/oauth/access_token

Then you call oacurl through the terminal. Depending on the language you use, there are different ways of calling a terminal action. In Python for example, you would use os.system()
java -cp oacurl-1.3.0.jar  com.google.oacurl.Login --service-provider=oauth.conf --consumer=oauth.conf

which would launch your browser and allow you to login and store your access token (along with other information) in 
~/.oacurl.properties 




--
Regards
Saimadhav Heblikar

--

---
You received this message because you are subscribed to the Google Groups "PES Opensource" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pes-opensourc...@googlegroups.com.
To post to this group, send email to pes-ope...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Regards,
Alok Shankar

Saimadhav Heblikar

unread,
Nov 28, 2014, 10:15:18 PM11/28/14
to pes-ope...@googlegroups.com

On Friday, November 28, 2014 1:05:30 AM UTC+5:30, alok.shankar.m wrote:
Check out oacurl. Basically, you create a config file, say oauth.conf

Hi Alok,

Thank you for the response. I'll check it and let you know soon how it goes. 
Reply all
Reply to author
Forward
0 new messages