简体   繁体   English

无法在Java中获得JSON响应

[英]Not getting JSON response in java

I think the issue is in the configuration setting for accessing protected resources, but I could be wrong here. 我认为问题出在用于访问受保护资源的配置设置中,但是我在这里可能是错误的。 I have tried both with SalesForce and Gmail.. 我已经尝试过使用SalesForce和Gmail。

Here is a sample configuration file that I am trying to use for gmail 这是我尝试用于gmail的示例配置文件

#scope=
grant_type=password
username=chitXXXXal@gmail.com
password=sumXXX3
client_id=685531072783-qu8rcpnv05800u1i3g8g3302eap1u914.apps.googleusercontent.com
#client_secret=
#access_token=
#refresh_token=
authentication_server_url=https://mail.google.com
resource_server_url=https://mail.google.com

I am very new to Oauth, and hence I am not able to understand how to get a JSON response. 我对Oauth非常陌生,因此无法理解如何获取JSON响应。 I am getting the following response 我收到以下回应

"text/html; charset=UTF-8" “文本/ html; charset = UTF-8”

which gives me the following error.. 这给了我以下错误。

"Cannot handle text/html; charset=UTF-8 content type. Supported content types include JSON, XML and URLEncoded" “无法处理text / html; charset = UTF-8内容类型。受支持的内容类型包括JSON,XML和URLEncoded”

Thanks in advance. 提前致谢。

您需要发送请求标头Accept: application/json

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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