diff --git a/CHANGES.md b/CHANGES.md index 898c2b4..2da4227 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,7 @@ * Added new API - Suspend Contract * Added new API - Resume Contract * Un/archive Activities start supporting a list of codes +* Added new method client.getAuthorizationUrl(oauthCallback), supported in mobile applications ## 0.1.7 * Added new API - Get brief profile summary diff --git a/doc/java-odesk-javadoc.zip b/doc/java-odesk-javadoc.zip index c51b484..02a7e36 100644 Binary files a/doc/java-odesk-javadoc.zip and b/doc/java-odesk-javadoc.zip differ diff --git a/example-android/app/src/main/java/com/odesk/example_odeskapi/MyActivity.java b/example-android/app/src/main/java/com/odesk/example_odeskapi/MyActivity.java index 040e18d..7b1509a 100644 --- a/example-android/app/src/main/java/com/odesk/example_odeskapi/MyActivity.java +++ b/example-android/app/src/main/java/com/odesk/example_odeskapi/MyActivity.java @@ -159,6 +159,9 @@ class ODeskAuthorizeTask extends AsyncTask { @Override protected String doInBackground(Void... params) { String authzUrl = client.getAuthorizationUrl(); + // if your api key type is 'mobile', possibly you want to use + // oauth_callback in your application, then use + //String authzUrl = client.getAuthorizationUrl("x-app://your_callback"); startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(authzUrl))); diff --git a/lib/java-odesk.jar b/lib/java-odesk.jar index f3239fc..65ca4ab 100644 Binary files a/lib/java-odesk.jar and b/lib/java-odesk.jar differ diff --git a/src/com/oDesk/api/OAuthClient.java b/src/com/oDesk/api/OAuthClient.java index 4fbf423..fc28051 100644 --- a/src/com/oDesk/api/OAuthClient.java +++ b/src/com/oDesk/api/OAuthClient.java @@ -100,22 +100,23 @@ public OAuthClient(Config properties) { mOAuthConsumer = new CommonsHttpOAuthConsumer(consumerKey, consumerSecret); } + /** + * Get authorization URL, and use provided callback + * + * @param oauthCallback URL, i.e. oauth_callback used in mobile applications + * @return URL for authorizing application + * */ + public String getAuthorizationUrl(String oauthCallback) { + return _getAuthorizationUrl(oauthCallback); + } + /** * Get authorization URL * * @return URL for authorizing application * */ public String getAuthorizationUrl() { - String url = null; - - try { - url = mOAuthProvider.retrieveRequestToken(mOAuthConsumer, ""); - } - catch (OAuthException e) { - e.printStackTrace(); - } - - return url; + return _getAuthorizationUrl(""); } /** @@ -246,6 +247,25 @@ public JSONObject delete(String url, HashMap params) throws JSON return sendPostRequest(url, METHOD_DELETE, params); } + /** + * Get authorization URL, use provided callback URL + * + * @param oauthCallback URL, i.e. oauth_callback + * @return URL for authorizing application + * */ + private String _getAuthorizationUrl(String oauthCallback) { + String url = null; + + try { + url = mOAuthProvider.retrieveRequestToken(mOAuthConsumer, oauthCallback); + } + catch (OAuthException e) { + e.printStackTrace(); + } + + return url; + } + /** * Send signed GET OAuth request *