Back to » Love the way you work.

Welcome to the oDesk Community! Connect here with fellow clients, contractors, and oDesk staff. Please review our Usage Policy.

oAuth Java desktop application

Hi all.

I can't understand how to use oAuth authorization in desktop app (JavaFX / Win 7). I have to use authorization due of job find API algorithm oAuth client is my application on my computer. So I don't see any reason to open browser to authorize myself, and receive token from browser... I look the way to make this without browser at all. Is it possible and reasonable in Java for desktop? It is fine to use web application, but may be a bit later...


I looked and tried and take java example. After adding libs, my NetBeans still marks red:


As I understand it is for web ... Is any examples for desktop?


Vote Result

Score: 0.0, Votes: 0
Pavel, a user, who uses an


a user, who uses an app (no matter that it is yours), must enter credentials and authorize the app - this is a requirement of OAuth protocol.
Because of security reasons, it is a requirement of RFC 5849 to enter credentials on the side of 'provider', in your case - oDesk.
Hence, you should provide an interface (e.g. open browser) to end user who will be able login at oDesk and authorize your app.

Try to check nonweb examples written in PHP as well.

Let's look example

Hi, Java example here:

I take few first lines. It stops with exception...
Profiler shows that it in: String url = api.getAuthUrl();
But it is not JSONException ...
Why api not get auth url?

String secret = "xxx";
String api_key = "xxx";
oDeskAPI api = new oDeskAPI(secret, api_key);
try {
// get auth url to open in system's browser
String url = api.getAuthUrl();
} catch (JSONException e) {

By the way in example "String" missed... why?

Here error message

Exception in Application start method
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at com.javafx.main.Main.launchApp(
at com.javafx.main.Main.main(
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(
at com.sun.javafx.application.LauncherImpl.access$000(
at com.sun.javafx.application.LauncherImpl$
Caused by: java.lang.NoClassDefFoundError: android/util/Log
at com.oDesk.api.oDeskAPI.normalizeParams(
at com.oDesk.api.oDeskAPI.normalizeParams(
at com.oDesk.api.oDeskAPI.calcApiSig(
at com.oDesk.api.oDeskAPI.calcApiSig(
at com.oDesk.api.oDeskAPI.getFrob(
at com.oDesk.api.oDeskAPI.getAuthUrl(
at oauthtest.OAuthTest.start(
at com.sun.javafx.application.LauncherImpl$
at com.sun.javafx.application.PlatformImpl$
at com.sun.javafx.application.PlatformImpl$
at Method)
... 1 more
Caused by: java.lang.ClassNotFoundException: android.util.Log
at Method)
at java.lang.ClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
... 14 more

It is an example for Token

It is an example for Token Based authorization.

So what?

"Token Based authorization" - What manual describes this? I looked rfc5849, so OAuth 1.0 is token based... I understand that clear!

I asked you about getAuthUrl() - why it not works as described in ? What to use instead ? Or OdeskApi works only on Android? Here from man, there is nothing about "Token Based authorization":

getAuthUrl() - return authentication url. The URL can be opened in system's browser for authorizing access to application.

What method of oDeskAPI I have to use first? Or is there any other ability to make "Temporary Credential Request" (rfc5849 p.5)

Pavlo, oDesk provides two


oDesk provides two ways of authentication, it is described in the documentation -

Please check it and you will find that this example is for Token Based (APIKeys) type. At the same type you are trying to use it as OAuth library, which is wrong.

In case you need Java lib for OAuth, please check official source that recommends a good list.

Thank for you patience

Hello, Maksym.

I'm sorry for my mistake, with two different authentication methods. Really i
find out what you talking about. I find the way to solve my problem. Thank you, and oDesk team for API!

So from here I offer to you look at Examples page. When I read it I don't understand that it shows two different approaches. May be "Token based" looks similar to "OAuth" because of RFC 5849 often use "token" terms. May be you will find some point to make this info more readable, in sens that it different. I searched method to solve problem but find that many people have the same question. Also it will be good to make little table on first page with platforms that tested authorization.

I tried to use OAuth (as recomended) with libraries. It become a trouble, because OAuth 1.0 project seems to stop. Examples with Java libraries on official site not started (most of them 2008-2009) community very weak, so I do not find the way to start it. Other sites that use OAuth more friendly with Java libs (as it seems to me).

I also tried not recommended Token Based, and also have unsolved problem. The example given not started on Java SE. I saw that it tested for android... but i don't use it.

So I have to solve the problem with method that I don't find on your manuals Smile. In my early question Dmitry pointed to log in in browser. I step this way and make JavaFX embedded in browser. It works! Now I test it.

With best regards, Pavlo.

Pavlo, thank you for your


thank you for your comprehensive reply.
We will check what we can do to make our documentation more readable.

As for OAuth, it is a standard that was released a couple years ago and contains enough libraries in majority of langueges, therefore, there is not a big number of newly created libs.

As for Java, i personally tried Signpost and it worked well, but it is up to you to decide what to choose according to needs of your project.