Domanda

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,

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top