3

PlayにJanrain認証を設定したい!GAE でホストされ、GAE モジュールを使用するプロジェクト。しかし、ログインしようとすると次のエラーが表示されます。

RuntimeException occured : Cannot parse JSON (check logs)

また、Play は次の行をエラーとして強調表示します。

JsonElement rpxJson = rpxRequest.get().getJson();

トークンのコールバックに使用するメソッドは次のとおりです。

public static void tokenCallback(String token) {
    Properties p = Play.configuration;
    // Try the driver
    String rpxApi = p.getProperty("login.rpx.apiKey");


    WSRequest rpxRequest = WS.url("http://rpxnow.com/api/v2/auth_info");
    // get RPX
    rpxRequest.setParameter("token", token);
    rpxRequest.setParameter("apiKey", rpxApi);

    JsonElement rpxJson = rpxRequest.get().getJson();
    JsonElement profile = rpxJson.getAsJsonObject().get("profile");
    String identifier = profile.getAsJsonObject().getAsJsonPrimitive("identifier").getAsString();

    welcome(identifier);

}

そして、ここに私が端末から得るエラーがあります:

Internal Server Error (500) for request POST /login/tokencallback

Execution exception (In /app/controllers/Login.java around line 27)
RuntimeException occured : Cannot parse JSON (check logs)

play.exceptions.JavaExecutionException: Cannot parse JSON (check logs)
    at play.mvc.ActionInvoker.invoke(ActionInvoker.java:237)
    at Invocation.HTTP Request(Play!)
Caused by: java.lang.RuntimeException: Cannot parse JSON (check logs)
    at play.libs.WS$HttpResponse.getJson(WS.java:668)
    at controllers.Login.tokenCallback(Login.java:27)
    at play.mvc.ActionInvoker.invokeWithContinuation(ActionInvoker.java:557)
    at play.mvc.ActionInvoker.invoke(ActionInvoker.java:508)
    at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:484)
    at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:479)
    at play.mvc.ActionInvoker.invoke(ActionInvoker.java:161)
    ... 1 more
Caused by: com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Expected EOF at line 2 column 1
    at com.google.gson.JsonParser.parse(JsonParser.java:65)
    at com.google.gson.JsonParser.parse(JsonParser.java:45)
    at play.libs.WS$HttpResponse.getJson(WS.java:665)
    ... 7 more
Caused by: com.google.gson.stream.MalformedJsonException: Expected EOF at line 2 column 1
    at com.google.gson.stream.JsonReader.syntaxError(JsonReader.java:1310)
    at com.google.gson.stream.JsonReader.peek(JsonReader.java:390)
    at com.google.gson.JsonParser.parse(JsonParser.java:60)
    ... 9 more

私に何ができる?この問題を解決するのを手伝ってください。

前もって感謝します。

4

2 に答える 2

1

URLをhttp://rpxnow.com/api/v2/auth_infoと呼ぶと、すぐにhttps://rpxnow.com/api/v2/auth_info(http s)にリダイレクトさます。JSONの回答は得られないのではないかと思いますが、Webサービスへの呼び出しにhttpリダイレクトコードが含まれています。

2つの可能性:

1)Webサービス呼び出しをhttps://rpxnow.com/api/v2/auth_infoに変更します。これで問題が解決し、失敗する可能性があります。

2)行JsonElement rpxJson = rpxRequest.get().getJson();を次のように変更します

HttpResponse httpResponse = rpxRequest.get();
Logger.log ( httpResponse.getString() ); 
if ( httpResponse.success() ) {
    JsonElement rpxJson = httpResponse.getJson();
} else {
    // fail gracefully
}

2行目に記録された回答の内容を報告します。

于 2012-08-22T06:53:30.263 に答える