0

Facebook seems to answer some API calls with text/plain instead of application/json. The oauth endpoint https://graph.facebook.com/oauth/access_token is one example. This seems to confuse the vert.x oauth client implementation. This is the call that fails:

oauth2.getToken(new JsonObject()
                        .put("code", code)
                        .put("redirect_uri", callbackUrl),
                res -> {
                    if (res.failed()) {
                       logger.warn(res.cause().getMessage());
                    } else {
                       AccessToken = res.result();
                       // ...etc...
                    }

The logged message is: Cannot handle content type: text/plain

So my question is, apart from the obvious solution of implementing my own getToken() method just for the Facebook provider, is there any other way to make the implementation parse the plain text response? It is a simple url encoded string like access_token=foo&expires=5179336

Is there a way to make Facebook answer in JSON that I am not aware of?

4

1 回答 1

0

使用更新版本的 Facebook API。在 v2.3 中,他们更改了 oauth/access_token 的格式以返回 JSON。

所以https://www.facebook.com/v2.3/oauth/access_tokenhttps://www.facebook.com/v2.7/oauth/access_token将返回 JSON 格式{"access_token": {TOKEN}, "token_type":{TYPE}, "expires_in":{TIME}}

如果您或您使用的 SDK 使用的是 uri https://graph.facebook.com/oauth/access_token,那么它使用的是 v2.0 API 而不是当前版本。

于 2016-07-24T22:43:30.173 回答