SkyDriveRESTAPIを使用してJavaデスクトップクライアントアプリケーションからOAuth2.0暗黙的付与を実装しようとしています。私は次のコードを使用します:
Desktop.getDesktop().browse(new URL(st.toString()).toURI());
JOptionPane.showMessageDialog(null, "Press ok to continue once you have authenticated.");
私のコードはWebブラウザーを開き、ユーザーにサインインするように要求すると、SkyDriveは次の形式でブラウザーのURLにアクセストークンを送信します。
https://login.live.com/oauth20_desktop.srf?lc=1033#access_token=EwAwAq1DBAAUlbRW.....
私がやりたいのは、Javaプログラムからこのアクセストークンを読み取ることです。コンソールからhttpconnectionを読み取ろうとしました:
HttpURLConnection con = (HttpURLConnection) url.openConnection();
BufferedReader reader = new BufferedReader( new InputStreamReader(url.openStream()));
while(reader.readLine()!=null){
System.out.println(reader.readLine());
しかし、javahttpurlconnectionはjavascript応答を処理しないようです。それは答えます:
<html dir="..... Windows Live ID requires JavaScript to sign in. This web browser either does not support JavaScript, or scripts are being blocked......<body onload="evt_LoginHostMobile_onload(event);">
では、Javaから直接アクセストークンを取得する方法はありますか?