我想在我的应用程序中使用OAuth2身份验证来使用访问令牌调用Eloqua API .
我按照链接http://docs.oracle.com/cloud/latest/marketingcs_gs/OMCAB/Developers/GettingStarted/Authentication/authenticate-using-oau中的说明进行操作,并使用 Resource Owner Password Credentials grant flow 获取访问令牌 .
POST https://login.eloqua.com/auth/oauth2/token
Authorization: Basic Q09NUEFOWVhcdXNlcjE6cGFzc3dvcmQxMjM=
{
"grant_type":"password",
"scope":"full",
"username":"testsite\\testuser",
"password":"user123"
}
但是我从java代码调用get token endpoint https://login.eloqua.com/auth/oauth2/token时遇到异常“ java.net.ConnectException: Connection timed out: connect ” .
我使用浏览器尝试了 endpoints 但得到了类似的错误 . 还尝试使用REST客户端访问 endpoints ,但同样连接错误 .
我无法理解 endpoints 为什么会给出连接超时异常 . 我也试过增加超时但同样的错误 .
因为我被卡住了,请指导我 .
是否有任何其他 endpoints 用于获取Eloqua访问令牌?
2 回答
下面是一个POSTMAN屏幕截图,以防它有帮助 . 还有一天写的屏幕截图不存在 . 不要在POSTMAN中使用内置的Auth,因为你需要使用以下代码对clientid:clientsecret进行base64编码 . 在Eloqua中创建应用程序时会提供这些值 .
请务必将内容类型包含为application / json和Authorization . 在Json中使用双反斜杠作为站点和用户名之间的用户名(
clientsite\\username
) .JSON正文应如下所示:
{"grant_type":"password","username":"clientsite\\username","password":"password"}
确保你做
POST
到login.eloqua.com/auth/oauth2/token
来自文档:
根据您的请求,您似乎错过了 redirect_uri 和 code . 尝试使用文档中的正文 Contract :http://docs.oracle.com/cloud/latest/marketingcs_gs/OMCAB/index.html#Developers/GettingStarted/Authentication/authenticate-using-oauth.htm