我使用此代码使用用户名和密码获取令牌,并且SAXParseException失败 - 有人可以帮忙吗?
代码
AuthenticationContext context = new AuthenticationContext("https://login.microsoftonline.com/common/",false, service);
Future<AuthenticationResult> future = context.acquireToken("<resource>", "clientId","userLogin","password",null);
AuthenticationResult result = future.get();
System.out.println("Access Token - " + result.getAccessToken());
System.out.println("Refresh Token - " + result.getRefreshToken());
System.out.println("ID Token - " + result.getIdToken());
日志中的异常:
[Correlation ID: null] Sent (null) Correlation Id is not same as received (null). [Correlation ID: null] Sent (null) Correlation Id is not same as received (null). [Correlation ID: 94f119e8-04bd-431e-9101-dbfb7d9c5a42] Request to acquire token failed. org.xml.sax.SAXParseException at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:257) at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:339) at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:121) at com.microsoft.aad.adal4j.MexParser.getPolicy(MexParser.java:101) at com.microsoft.aad.adal4j.MexParser.getWsTrustEndpointFromMexResponse(MexParser.java:141) at com.microsoft.aad.adal4j.WSTrustRequest.execute(WSTrustRequest.java:84) at com.microsoft.aad.adal4j.AuthenticationContext.processPasswordGrant(AuthenticationContext.java:990) at com.microsoft.aad.adal4j.AuthenticationContext.access$000(AuthenticationContext.java:69) at com.microsoft.aad.adal4j.AuthenticationContext$1.call(AuthenticationContext.java:178) at com.microsoft.aad.adal4j.AuthenticationContext$1.call(AuthenticationContext.java:168) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) [Fatal Error] :12:10: DOCTYPE is disallowed when the feature "http://apache.org/xml/features/disallow-doctype-decl" set to true. Exception in thread "main" java.util.concurrent.ExecutionException: org.xml.sax.SAXParseException; lineNumber: 12; columnNumber: 10; DOCTYPE is disallowed when the feature "http://apache.org/xml/features/disallow-doctype-decl" set to true. at java.util.concurrent.FutureTask.report(FutureTask.java:122) at java.util.concurrent.FutureTask.get(FutureTask.java:206) at O365RestClient.main(O365RestClient.java:32) Caused by: org.xml.sax.SAXParseException; lineNumber: 12; columnNumber: 10; DOCTYPE is disallowed when the feature "http://apache.org/xml/features/disallow-doctype-decl" set to true. at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:257) at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:339) at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:121) at com.microsoft.aad.adal4j.MexParser.getPolicy(MexParser.java:101) at com.microsoft.aad.adal4j.MexParser.getWsTrustEndpointFromMexResponse(MexParser.java:141) at com.microsoft.aad.adal4j.WSTrustRequest.execute(WSTrustRequest.java:84) at com.microsoft.aad.adal4j.AuthenticationContext.processPasswordGrant(AuthenticationContext.java:990) at com.microsoft.aad.adal4j.AuthenticationContext.access$000(AuthenticationContext.java:69) at com.microsoft.aad.adal4j.AuthenticationContext$1.call(AuthenticationContext.java:178) at com.microsoft.aad.adal4j.AuthenticationContext$1.call(AuthenticationContext.java:168) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) [Correlation ID: 94f119e8-04bd-431e-9101-dbfb7d9c5a42] Request to acquire token failed. org.xml.sax.SAXParseException; lineNumber: 12; columnNumber: 10; DOCTYPE is disallowed when the feature "http://apache.org/xml/features/disallow-doctype-decl" set to true. at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:257) at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:339) at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:121) at com.microsoft.aad.adal4j.MexParser.getPolicy(MexParser.java:101) at com.microsoft.aad.adal4j.MexParser.getWsTrustEndpointFromMexResponse(MexParser.java:141) at com.microsoft.aad.adal4j.WSTrustRequest.execute(WSTrustRequest.java:84) at com.microsoft.aad.adal4j.AuthenticationContext.processPasswordGrant(AuthenticationContext.java:990) at com.microsoft.aad.adal4j.AuthenticationContext.access$000(AuthenticationContext.java:69) at com.microsoft.aad.adal4j.AuthenticationContext$1.call(AuthenticationContext.java:178) at com.microsoft.aad.adal4j.AuthenticationContext$1.call(AuthenticationContext.java:168) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)