Could not get response from Google API's via Java servlet in GAE

45 views
Skip to first unread message

foot...@umiack.com

unread,
Mar 11, 2015, 6:20:40 AM3/11/15
to google-a...@googlegroups.com
I can get the response from Google API's via web browser. It is say,

Access to 


by some web browser, and get response

{
 "kind": "blogger#blog",
 "id": "4871538073781423026",
 "name": "SoffeeShop",
 "description": "",
 "published": "2012-10-24T23:55:32+09:00",
 "updated": "2015-03-04T14:31:00+09:00",
 "url": "http://soffeeshop.blogspot.com/",
 "selfLink": "https://www.googleapis.com/blogger/v3/blogs/4871538073781423026",
 "posts": {
  "totalItems": 58,
  "selfLink": "https://www.googleapis.com/blogger/v3/blogs/4871538073781423026/posts"
 },
 "pages": {
  "totalItems": 0,
  "selfLink": "https://www.googleapis.com/blogger/v3/blogs/4871538073781423026/pages"
 },
 "locale": {
  "language": "en",
  "country": "",
  "variant": ""
 }
}

Although, when I do REST in the servlet in GAE, like

URL url = new URL("https://www.googleapis.com/blogger/v3/blogs/4871538073781423026?access_token=XXXXXXXXX");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setRequestProperty("X-Appengine-Inbound-Appid", "XXXXX");
connection.setRequestProperty("Accept", "application/json");
connection.setRequestProperty("Host", "googleapis.com");

or

URL url = new URL("https://www.googleapis.com/blogger/v3/blogs/4871538073781423026);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setRequestProperty("Authorization", "Bearer " + access_token); 
connection.setRequestProperty("X-Appengine-Inbound-Appid", "XXXXX"); connection.setRequestProperty("Accept", "application/json"); connection.setRequestProperty("Host", "googleapis.com");

i just got "404 Not Found" Error. 

I could get access_token with OAuth2 using HttpURLConnection in the same servlet in GAE, just could not do access to google API's. So, it's mean Http Connections are working well to access to other servers.

Why I could not access only Google API's via servlet in GAE? Please help me...

Michael

unread,
Mar 11, 2015, 2:06:51 PM3/11/15
to google-a...@googlegroups.com
This sort of programming/development question would be better directed to Stack Overflow's App Engine tag. I recommend posting there for more technical issues as it is more likely that you will get a solution to your problem.

foot...@umiack.com

unread,
Mar 12, 2015, 4:32:32 AM3/12/15
to google-a...@googlegroups.com
Thanks Michael :-) I will post there.

2015年3月12日木曜日 3時06分51秒 UTC+9 Michael:
Reply all
Reply to author
Forward
0 new messages