我正在使用Eclipse
来运行Gmail API
Java快速入门计划。 (https://developers.google.com/gmail/api/quickstart/quickstart-java)。
我已经能够获得authorization code
。但是,我无法找到将其传达给程序的方法。
似乎通过命令行数据输入来预期此代码。但是,我不知道在Eclipse中如何做到这一点。
作为替代方案,我将授权代码直接放入程序中。像这样:
//System.out.println("Please open the following URL in your browser then type"
// + " the authorization code:\n" + url);
// Read code entered by user.
// BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String code = "valueOfTheAuthorizationCode";
但这给了我错误:
Exception in thread "main" com.google.api.client.auth.oauth2.TokenResponseException: 400 Bad Request
{
"error" : "invalid_grant"
}
非常感谢任何帮助。
朱迪