Skip to content

Commit e2ecdac

Browse files
committed
add new API Asana (https://asana.com/) (thanks to https://github.com/joestazak)
1 parent 4f48736 commit e2ecdac

5 files changed

Lines changed: 32 additions & 40 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ ScribeJava support out-of-box several HTTP clients:
5252

5353
### Supports all major 1.0a and 2.0 OAuth APIs out-of-the-box
5454

55-
* Asana (https://app.asana.com/) [example](https://github.com/scribejava/scribejava/blob/master/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/AsanaExample.java)
55+
* Asana (https://asana.com/) [example](https://github.com/scribejava/scribejava/blob/master/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/AsanaExample.java)
5656
* Automatic (https://www.automatic.com/) [example](https://github.com/scribejava/scribejava/blob/master/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/AutomaticExample.java)
5757
* AWeber (http://www.aweber.com/) [example](https://github.com/scribejava/scribejava/blob/master/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/AWeberExample.java)
5858
* Box (https://www.box.com/) [example](https://github.com/scribejava/scribejava/blob/master/scribejava-apis/src/test/java/com/github/scribejava/apis/examples/Box20Example.java)

changelog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* fix Muplipart request model and implement it for a jdk HTTP client (thanks to https://github.com/NTPape)
33
* remove any Google+ mention (switch to clean Google OAuth2) (thanks to https://github.com/fvasco)
44
* fix Microsoft Azure AD v1.0 and v2.0 (thanks to https://github.com/kenpusney and https://github.com/oscararias)
5+
* add new API Asana (https://asana.com/) (thanks to https://github.com/joestazak)
56

67
[6.2.0]
78
* add new API Microsoft Azure Active Directory (Azure AD) 2.0 (thanks to https://github.com/rzukow and https://github.com/dgrudenic)

scribejava-apis/src/main/java/com/github/scribejava/apis/Asana20.java

Lines changed: 0 additions & 33 deletions
This file was deleted.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.github.scribejava.apis;
2+
3+
import com.github.scribejava.core.builder.api.DefaultApi20;
4+
5+
public class Asana20Api extends DefaultApi20 {
6+
7+
protected Asana20Api() {
8+
}
9+
10+
private static class InstanceHolder {
11+
private static final Asana20Api INSTANCE = new Asana20Api();
12+
}
13+
14+
public static Asana20Api instance() {
15+
return InstanceHolder.INSTANCE;
16+
}
17+
18+
@Override
19+
public String getAccessTokenEndpoint() {
20+
return "https://app.asana.com/-/oauth_token";
21+
}
22+
23+
@Override
24+
protected String getAuthorizationBaseUrl() {
25+
return "https://app.asana.com/-/oauth_authorize";
26+
}
27+
}

scribejava-apis/src/test/java/com/github/scribejava/apis/examples/AsanaExample.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.github.scribejava.apis.examples;
22

3-
import com.github.scribejava.apis.Asana20;
3+
import com.github.scribejava.apis.Asana20Api;
44
import com.github.scribejava.core.builder.ServiceBuilder;
55
import com.github.scribejava.core.model.OAuth2AccessToken;
66
import com.github.scribejava.core.model.OAuthRequest;
@@ -9,8 +9,6 @@
99
import com.github.scribejava.core.oauth.OAuth20Service;
1010

1111
import java.io.IOException;
12-
import java.util.HashMap;
13-
import java.util.Map;
1412
import java.util.Random;
1513
import java.util.Scanner;
1614
import java.util.concurrent.ExecutionException;
@@ -20,7 +18,6 @@ public class AsanaExample {
2018
private static final String PROTECTED_RESOURCE_URL = "https://app.asana.com/api/1.0/users/me";
2119

2220
private AsanaExample() {
23-
2421
}
2522

2623
public static void main(String... args) throws IOException, InterruptedException, ExecutionException {
@@ -30,7 +27,8 @@ public static void main(String... args) throws IOException, InterruptedException
3027
final OAuth20Service service = new ServiceBuilder(apiKey)
3128
.apiSecret(apiSecret)
3229
.callback("https://localhost/")
33-
.build(Asana20.instance());
30+
.state(secretState)
31+
.build(Asana20Api.instance());
3432
final Scanner in = new Scanner(System.in);
3533

3634
// Obtain Auth URL
@@ -81,5 +79,4 @@ public static void main(String... args) throws IOException, InterruptedException
8179
System.out.println();
8280
System.out.println("Thats it man! Go and build something awesome with ScribeJava! :)");
8381
}
84-
8582
}

0 commit comments

Comments
 (0)