草庐IT

oauth2resttemplate

全部标签

java - 为什么我在使用 RestTemplate 获取数据时总是得到 403?

这个问题在这里已经有了答案:403ForbiddenwithJavabutnotwebbrowser?(4个回答)关闭4年前。我正在尝试获取数据,但总是使用RestTemplate获取403(Forbidden)。但是当我尝试org.apache.http.client.HttpClient时,一切正常。我还可以在我的机器上使用Postman获取数据。代码很简单,但我不知道哪里出了问题。publicObjectget(){try{RestTemplaterestTemplate=newRestTemplate();Objectresult=restTemplate.getForObje

java - 如果主机离线,重试 java RestTemplate HTTP 请求

您好,我正在使用springRestTemplate来调用RESTAPI。API可能非常缓慢甚至离线。我的应用程序通过一个接一个地发送数千个请求来构建缓存。响应也可能很慢,因为它们包含大量数据。我已经将超时时间增加到120秒。我现在的问题是API可以脱机并且我得到一个org.apache.http.conn.ConnectionPoolTimeoutException:Timeoutwaitingforconnectionfrompool异常。API离线的情况下,应用程序应该等待并重试,直到API再次在线。我可以在RestTemplate中实现这一点,而无需自己构建异常循环吗?谢谢!

java - 如果主机离线,重试 java RestTemplate HTTP 请求

您好,我正在使用springRestTemplate来调用RESTAPI。API可能非常缓慢甚至离线。我的应用程序通过一个接一个地发送数千个请求来构建缓存。响应也可能很慢,因为它们包含大量数据。我已经将超时时间增加到120秒。我现在的问题是API可以脱机并且我得到一个org.apache.http.conn.ConnectionPoolTimeoutException:Timeoutwaitingforconnectionfrompool异常。API离线的情况下,应用程序应该等待并重试,直到API再次在线。我可以在RestTemplate中实现这一点,而无需自己构建异常循环吗?谢谢!

Spring OAuth 2 : public access to a resource

如何在SpringSecurityOAuth-2Rest应用程序中允许特定URL中的公共(public)访问。我已保护所有以/rest/**开头的URL,但希望将/rest/about公开,因此我不需要用户进行身份验证访问它。我尝试使用permitAll()但它仍然需要请求中的token。这是我的HttpSecurity配置:@Configuration@EnableResourceServerprotectedstaticclassResourceServerConfigurationextendsResourceServerConfigurerAdapter{@Overridepu

Spring OAuth 2 : public access to a resource

如何在SpringSecurityOAuth-2Rest应用程序中允许特定URL中的公共(public)访问。我已保护所有以/rest/**开头的URL,但希望将/rest/about公开,因此我不需要用户进行身份验证访问它。我尝试使用permitAll()但它仍然需要请求中的token。这是我的HttpSecurity配置:@Configuration@EnableResourceServerprotectedstaticclassResourceServerConfigurationextendsResourceServerConfigurerAdapter{@Overridepu

java - 向 Spring OAuth2 Auth Server 添加多个客户端

我有SpringOAuth授权服务器,我想添加对多个客户端(id)的支持。我这样配置客户端:clients.inMemory().withClient(client).secret(clientSecret).resourceIds(resourceId).authorizedGrantTypes("client_credentials","password","refresh_token","implicit","authorization_code").authorities("ROLE_USER").scopes("read","write").autoApprove(true)

java - 向 Spring OAuth2 Auth Server 添加多个客户端

我有SpringOAuth授权服务器,我想添加对多个客户端(id)的支持。我这样配置客户端:clients.inMemory().withClient(client).secret(clientSecret).resourceIds(resourceId).authorizedGrantTypes("client_credentials","password","refresh_token","implicit","authorization_code").authorities("ROLE_USER").scopes("read","write").autoApprove(true)

spring - 实体的 RestTemplate 帖子

我的post方法被调用,但我的个人资料为空。这种方法有什么问题?我必须使用@Requestbody来使用RestTemplate吗?Profileprofile=newProfile();profile.setEmail(email);Stringresponse=restTemplate.postForObject("http://localhost:8080/user/",profile,String.class);@RequestMapping(value="/",method=RequestMethod.POST)public@ResponseBodyObjectpostUse

spring - 实体的 RestTemplate 帖子

我的post方法被调用,但我的个人资料为空。这种方法有什么问题?我必须使用@Requestbody来使用RestTemplate吗?Profileprofile=newProfile();profile.setEmail(email);Stringresponse=restTemplate.postForObject("http://localhost:8080/user/",profile,String.class);@RequestMapping(value="/",method=RequestMethod.POST)public@ResponseBodyObjectpostUse

java - 有没有办法在 Spring RestTemplate DELETE 调用中传递 header 信息

在SpringRestTemplate中,我们有以下删除方法。@Overridepublicvoiddelete(Stringurl,Object...urlVariables)throwsRestClientException{execute(url,HttpMethod.DELETE,null,null,urlVariables);}@Overridepublicvoiddelete(Stringurl,MapurlVariables)throwsRestClientException{execute(url,HttpMethod.DELETE,null,null,urlVaria