|
16 | 16 | public final class Box20Example { |
17 | 17 |
|
18 | 18 | private static final String NETWORK_NAME = "Box"; |
19 | | - private static final String PROTECTED_RESOURCE_URL = "https://app.box.com/files"; |
| 19 | + private static final String PROTECTED_RESOURCE_URL = "https://app.box.com/profile"; |
20 | 20 |
|
21 | 21 | private Box20Example() { |
22 | 22 | } |
@@ -67,11 +67,23 @@ public static void main(String... args) throws IOException { |
67 | 67 |
|
68 | 68 | // Trade the Request Token and Verfier for the Access Token |
69 | 69 | System.out.println("Trading the Request Token for an Access Token..."); |
70 | | - OAuth2AccessToken accessToken = service.getAccessToken(code); |
| 70 | + final OAuth2AccessToken accessToken = service.getAccessToken(code); |
71 | 71 | System.out.println("Got the Access Token!"); |
72 | 72 | System.out.println("(If you're curious, it looks like this: " + accessToken |
73 | 73 | + ", 'rawResponse'='" + accessToken.getRawResponse() + "')"); |
74 | 74 |
|
| 75 | + System.out.println(); |
| 76 | + |
| 77 | + // Now let's go and ask for a protected resource! |
| 78 | + System.out.println("Now we're going to access a protected resource..."); |
| 79 | + final OAuthRequest request = new OAuthRequest(Verb.GET, PROTECTED_RESOURCE_URL, service); |
| 80 | + service.signRequest(accessToken, request); |
| 81 | + final Response response = request.send(); |
| 82 | + System.out.println("Got it! Lets see what we found..."); |
| 83 | + System.out.println(); |
| 84 | + System.out.println(response.getCode()); |
| 85 | + System.out.println(response.getBody()); |
| 86 | + |
75 | 87 | System.out.println("Thats it man! Go and build something awesome with ScribeJava! :)"); |
76 | 88 | } |
77 | 89 |
|
|
0 commit comments