Skip to content
This repository has been archived by the owner on Oct 9, 2018. It is now read-only.

Commit

Permalink
update for version 0.1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
Maksym Novozhylov committed Sep 23, 2014
1 parent 51f2774 commit d69f2e7
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file modified doc/java-odesk-javadoc.zip
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ class ODeskAuthorizeTask extends AsyncTask<Void, Void, String> {
@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)));

Expand Down
Binary file modified lib/java-odesk.jar
Binary file not shown.
40 changes: 30 additions & 10 deletions src/com/oDesk/api/OAuthClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -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("");
}

/**
Expand Down Expand Up @@ -246,6 +247,25 @@ public JSONObject delete(String url, HashMap<String, String> 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
*
Expand Down

0 comments on commit d69f2e7

Please sign in to comment.