来自Oracle.dbtools.comn.util.Base64.base64ToByteArray的Oracle O



我的需要是从Oracle ORDS中获得一个具有已验证用户的令牌。我将按照本文档使用fetch开发一个javascript。

我被卡住了

$curl-i-k--用户3NvJRo_a0UwGKx7Q-kivtA.:F5WVwyrWxXj3ykmhSONldQ。。--data"grant_type=client_credentials"https://ol7-121.localdomain:8443/ords/pdb1/testuser1/oauth/tokenHTTP/1.1 200 OK服务器:Apache Coyote/1.1 X-Frame-Options:SAMEORIGIN内容类型:application/json传输编码:分块日期:周三,2016年6月29日12:07:02 GMT

{"access_token":"-zYl-sFyB2iLicAHw2TsRA..","token_type":"bearer","expires_in":3600}$

基于此示例,我将my curl设置为如下,并在主机的命令行中对其进行测试,它将按预期使用有效令牌进行响应

curl -i -k --user Uj1xXqz5pNRoSubJ6v3Hdg..:Npvid_qzM75NrO978NKl0A.. --data "grant_type=client_credentials" http://myhost:8080/ords/myrest/oauth/token

接下来,我尝试以这种方式将验证过的curl commad转换为提取请求,但它的响应是500内部服务器错误

fetch('http://myhost:8080/ords/myrest/oauth/token',
{
method: 'POST',
headers: {
'Authorization': 'Basic Uj1xXqz5pNRoSubJ6v3Hdg..:Npvid_qzM75NrO978NKl0A..'
},
body: 'grant_type=client_credentials'
})...

尽管我在寻找和尝试不同的变体,但我无法弄清楚我做错了什么或错过了什么。我们将不胜感激。

************编辑:根据评论中的建议,我尝试更进一步************

关于OPTIONS请求,我检查了网络活动(作为第一次尝试,我使用浏览器的开发工具),发现了带有方法OPTIONS和状态代码200的标题。

之后,考虑到我已经通过Tomcat部署了ORDS,我在/app/oracle/ora_rest/params中修改了default.xml,如本文档所述。现在我可以检索错误的完整描述,并且我仍在尝试配置/检查日志。

错误的完整轨迹是:

InternalServerException[statusCode=500,reasons=[出现以下消息的意外错误:字符串长度必须是四的倍数。]]位于oracle.dbtools.http.errors.ServletResponseExceptionMapper.mapError(Servlet响应异常映射器.java:84)位于oracle.dbtools.http.errors.ErrorPageRenderer。(ErrorPageRender.java:43)位于oracle.dbtools.http.errors.ErrorPageRenderer。(ErrorPageRender.java:35)位于oracle.dbtools.http.errors.ErrorPageFilter.doFilter(ErrorPageFilter.java:119)在oracle.dbtools.http.filters.HttpFilter.doFilter(HttpFilter.java:47)位于oracle.dbtools.http.filters.FilterChainImpl.doFilter(FilterChainImpl.java:64)位于oracle.dbtools.http.auth.ForceAuthFilter.doFilter(ForceAuthFilter.java:44)在oracle.dbtools.http.filters.HttpFilter.doFilter(HttpFilter.java:47)位于oracle.dbtools.http.filters.FilterChainImpl.doFilter(FilterChainImpl.java:64)在oracle.dbtools.http.filters.filters(filters.java:47)位于oracle.dbtools.http.entrypoint.entrypoint.service(entrypoint.java:82)位于oracle.dbtools.http.entrypoint.EntryPointServlet.service(EntryPointServlet.java:49)位于javax.servlet.httpHttpServlet.service(HttpServlet.java:742)位于oracle.dbtools.rt.web.HttpEndpointBase.dispatchableServices(HttpEndpointBase.java:116)位于oracle.dbtools.rt.web.HttpEndpointBase.service(HttpEndpointBase.java:81)位于javax.servlet.httpHttpServlet.service(HttpServlet.java:742)网址:org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)网址:org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)网址:org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)网址:org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)网址:org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)网址:org.apache.catalina.core.StandardWrapperValv.invoke(StandardWrapperValve.java:199)网址:org.apache.catalina.core.StandardContextValv.invoke(StandardContextValv.java:96)网址:org.apache.catalina.authenticator.AuthenticatorBase.ioke(AuthenticatorBase.java:475)网址:org.apache.catalina.core.StandardHostValv.invoke(StandardHostValv.java:140)网址:org.apache.catalina.vals.ErrorReportValve.ioke(ErrorReportValve.java:80)网址:org.apache.catalina.vals.AbstractAccessLogValv.invoke(AbstractAccessLogValve.java:624)网址:org.apache.catalina.core.StandardEngineValv.invoke(StandardEngineValv.java:87)网址:org.apache.catalina.connecter.CoyoteAdapter.service(Coyotedapter.java:341)网址:org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:495)网址:org.apache.coyote.AbstractProcessorLight.produce(AbstractProcessorLight.java:66)网址:org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:767)网址:org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1354)网址:org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)位于java.util.concurrent.ThreadPoolExecutiator.runWorker(ThreadPoolExecutiator.java:1142)位于java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)网址:org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)在java.lang.Thread.run(线程.java:745)由:java.lang.IollegalArgumentException引起:字符串长度必须是四的倍数。位于oracle.dbtools.common.util.Base64.base64ToByteArray(Base64.java:43)位于oracle.dbtools.common.util.Base64.base64ToByteArray(Base64.java:23)位于oracle.dbtools.http.auth.HttpBasicAuthenticationHandler.extractCredentials(HttpBasicAuthocationHandler.java:38)位于oracle.dbtools.http.auth.HttpBasicAuthenticationHandler。(HttpBasicAuthenticationHandler.java:21)位于oracle.dbtools.http.auth.HttpBasicAuthentication.(HttpBasicAuthAuthentication.java:15)位于oracle.dbtools.http.auth.AuthenticationFilter.authenticate(AuthenticationFilter.java:69)位于oracle.dbtools.http.auth.AuthionFilter.doFilter(AuthenticationFilter.java:62)在oracle.dbtools.http.filters.HttpFilter.doFilter(HttpFilter.java:47)位于oracle.dbtools.http.filters.FilterChainImpl.doFilter(FilterChainImpl.java:64)位于oracle.dbtools.url.mapping.RequestMapperImpl.doFilter(RequestMapperImpl.java:125)位于oracle.dbtools.url.mapping.URLMappingBase.doFilter(URLMappingBase.java:103)位于oracle.dbtools.url.mapping.filter.URLMappingFilter.doFilter(URLMappingFilter.java:124)在oracle.dbtools.http.filters.HttpFilter.doFilter(HttpFilter.java:47)位于oracle.dbtools.http.filters.FilterChainImpl.doFilter(FilterChainImpl.java:64)位于oracle.dbtools.http.cors.CORSResponseFilter.doFilter(CORSResponse Filter.java:83)位于oracle.dbtools.http.filters.HttpResponseFilter.doFilter(HttpResponseFilter.java:45)位于oracle.dbtools.http.filters.FilterChainImpl.doFilter(FilterChainImpl.java:64)位于oracle.dbtools.http.errors.ErrorPageFilter.doFilter(ErrorPageFilter.java:94)…还有34个

[…]由:java.lang.IollegalArgumentException引起:字符串长度必须是四的倍数。在oracle.dbtools.common.util.Base64.base64ToByteArray(Base64.java:43)[…]

让我修改通过client_id:client_secret(authdata)base64转换的(window.btoa(authdata))的请求头,如下所示:

fetch('http://myhost:8080/ords/myrest/oauth/token',
{
method: 'POST',
headers: {
'Authorization': 'Basic ' + window.btoa(authdata),
'Content-Type': 'application/x-www-form-urlencoded'
},
body: 'grant_type=client_credentials'
})...

fetch现在使用access_token值正确响应,我可以使用它发出授权的GET请求。

最新更新