forked from resinas/OAuthClient
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOAuthSample.java
More file actions
43 lines (27 loc) · 885 Bytes
/
OAuthSample.java
File metadata and controls
43 lines (27 loc) · 885 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package es.us.oauthclient;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import com.google.api.client.http.HttpResponse;
/**
* A sample application that demonstrates how the library can be used to authenticate
*
*/
class OAuthSample {
public static void main(String[] args) {
final API api = new API( new GoogleConfigInterface() );
try {
api.authorize( Arrays.asList("email") );
//todo Change this address.
HttpResponse resp = api.get( "https://www.googleapis.com/userinfo/v2/me" );
System.out.println( resp.parseAsString() );
// Success!
return;
} catch (IOException e) {
System.err.println(e.getMessage());
} catch (Throwable t) {
t.printStackTrace();
}
System.exit(1);
}
}