Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OAuth protocol / java- Scribe : storing the token?

I've been playing with the [scribe API][1] and a basic example e.g:

https://github.com/fernandezpablo85/scribe-java/blob/master/src/test/java/org/scribe/examples/TwitterExample.java

In a command line oriented interface, the user is asked to open a web-browser and to copy'n paste the "accessToken".

Once the user has copied the "accessToken", I want to avoid this "browser step" in the later invocations of the tool: can I store the "accessToken" somewhere to re-use it later ? would it work for any server (Twitter ? Flickr... ) ? How should I change the code to reuse the previously saved "accessToken" ?

Thanks,

like image 610
Pierre Avatar asked Jul 19 '26 04:07

Pierre


1 Answers

In the case of the Twitter API you should store the access token as it represents the user's permission for your application to access their account.

However, bear in mind that the token may be revoked by the user, so ensure your application is able to obtain it again.

To change the code to use a previously saved accessToken all you would have to do is look up the token for the current user - perhaps it's retrieved from a database, and then start making requests. Essentially you would just skip the whole "obtaining request token" block of code.

like image 73
Jonathan Avatar answered Jul 20 '26 18:07

Jonathan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!