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 44 45 46 47 48 49 50 51 52 53
|
private static final HttpTransport TRANSPORT = new NetHttpTransport();
private static final JsonFactory JSON_FACTORY = new JacksonFactory();
static String SERVICE_ACCOUNT_EMAIL = "xxxxxxx-xxxxxxx45xxxxxxv@developer.gserviceaccount.com";
private static Bigquery bigquery;
public static void main(String[] args) throws IOException, InterruptedException, GeneralSecurityException
{
try
{
GoogleCredential credential = new GoogleCredential.Builder().setTransport(TRANSPORT)
.setJsonFactory(JSON_FACTORY)
.setServiceAccountId(SERVICE_ACCOUNT_EMAIL)
.setServiceAccountScopes(Collections.singleton(BigqueryScopes.BIGQUERY))
.setServiceAccountPrivateKeyFromP12File(new File("dfgdfgfdgdfg.p12"))
.build();
credential.refreshToken();
String token = credential.getAccessToken();
System.out.println(token);
String url = "https://www.googleapis.com/admin/directory/v1/groups?key=xxxxxxxxxxxxx";
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(url);
post.setHeader("User-Agent", USER_AGENT);
List<NameValuePair> urlParameters = new ArrayList<NameValuePair>();
urlParameters.add(new BasicNameValuePair("email", "totezr@tyut-jghjghj.fr"));
post.setEntity(new UrlEncodedFormEntity(urlParameters));
HttpResponse response = client.execute(post);
}
catch(Exception e)
{
System.out.println(e);
//e.printStackTrace();
}
}
} |
Partager