Ich versuche an den access_token ran zu kommen und habe dazu folgenden http post erstellt. Wenn ich das ganze ausführe bekomme ich immer folgende Fehlermeldung:
[code=Java]
<HTML>
<HEAD>
<TITLE>Client must specify either client_id or client_assertion, not both</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Client must specify either client_id or client_assertion, not both</H1>
<H2>Error 400</H2>
</BODY>
</HTML>
public class Test {
public static void main(String[] args) {
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(
"https://accounts.google.com/o/oauth2/token");
try {
final HttpEntity entity = new UrlEncodedFormEntity(Arrays.asList(
new BasicNameValuePair("cliend_id", "xxxxxxxxxxxxx"),
new BasicNameValuePair("client_secret", "xxxxxxxxxxx"),
new BasicNameValuePair("redirect_uri","xxxxxxxxx"),
new BasicNameValuePair("grant_type", "authorization_code"),
new BasicNameValuePair("code", "xxxxxxxx")));
post.setEntity(entity);
HttpResponse response = client.execute(post);
StringBuilder builder = new StringBuilder();
String line;
BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
while((line = reader.readLine()) != null) {
builder.append(line);
System.out.println(line);
}
JSONObject json = null;
try {
json = new JSONObject(builder.toString());
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println(json);
} catch (IOException e) {
e.printStackTrace();
}
}
}
[/code]