为okta AuthorizedRequest获取异常

时间:2018-08-18 15:46:43

标签: okta okta-api

获取AuthorizedRequest的异常, 08-18 21:08:39.841 20347-20419 / com.okta.appauth.android.example E / OktaAppAuth:向请求添加授权标头时发生异常                                                                                java.io.FileNotFoundException:http://XXXX.XXXX.XXX.XX:8000/api/data                                                                                    在com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:254)                                                                                    在com.okta.appauth.android.OktaAppAuth $ 9.run(OktaAppAuth.java:624)                                                                                    在java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:428)                                                                                    在java.util.concurrent.FutureTask.run(FutureTask.java:237)                                                                                    在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)                                                                                    在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:607)                                                                                    在java.lang.Thread.run(Thread.java:762)

     private void callMessagesApi() {
       Log.i(TAG, "mOktaAppAuth Log :" + mOktaAppAuth);
       mOktaAppAuth.performAuthorizedRequest(new OktaAppAuth.BearerAuthRequest() {
       @NonNull
       @Override
        public HttpURLConnection createRequest() throws Exception {
         try {
             final URL myUrl = new URL("http://XXXX.XXX.XXXX.:8000/api/data");
             HttpURLConnection conn = (HttpURLConnection) myUrl.openConnection();
             conn.setInstanceFollowRedirects(false); // recommended during authorized calls
             return conn;
         } catch (MalformedURLException e) {
             Log.i(TAG, e.getLocalizedMessage());
         }
         return null;
     }

    @Override
    public void onSuccess(@NonNull InputStream inputStream) {
        myDataString=inputStream.toString();
        runOnUiThread(() -> displayAuthorizationInfo());

    }

    @Override
    public void onTokenFailure(@NonNull AuthorizationException e) {
        // Handle failure to acquire new tokens from Okta
    }

    @Override
    public void onFailure(int i, Exception e) {
        // Handle failure to make your authorized request or a response with a 4xx or
        // 5xx HTTP status response code
    }
});

 }

0 个答案:

没有答案