简体   繁体   中英

Google authorization access API via browser

I have a problem with my Google API. I would like to avoid going through a browser to retrieve my access authorization. I would like to retrieve the code directly into a variable. This is the kind of URL that I sent :

https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=2131233123321332&scope=https://www.googleapis.com/auth/admin.directory.group%20https://www.googleapis.com/auth/admin.directory.group.readonly&redirect_uri=https://tito.com

HttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet("https://accounts.google.com/o/oauth2/auth?access_type=online&approval_prompt=auto&client_id=22fdgdfg40-1gmgdfggdps0hfol.apps.googleusercontent.com&redirect_uri=https://tito.com/&response_type=code&scope=https://www.googleapis.com/auth/admin.directory.group%20https://www.googleapis.com/auth/admin.directory.group.readonly");
HttpResponse responses = client.execute(httpget);

HttpParams param = responses.getParams();

responses.getParams().getParameter("code");
System.out.println(responses.getParams().getParameter("code"));
System.out.println("Response Code : " + responses.getStatusLine().getStatusCode());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM