spring - Missing client_id when accessing token with linkedIn -
i have extended spring security oauth example social-auth-server, linkedin added third authentication option. project described in tutorial hosting authorization server.
source code: https://github.com/spring-guides/tut-spring-boot-oauth2/tree/master/auth-server
how configure client add client_id?
linkedin properties:
linkedin: client: clientid: xxx clientsecret: yyy accesstokenuri: https://www.linkedin.com/oauth/v2/accesstoken userauthorizationuri: https://www.linkedin.com/oauth/v2/authorization resource: userinfouri: https://api.linkedin.com/v1/people/~?format=json
logs:
uth2clientauthenticationprocessingfilter : request process authentication g.c.authorizationcodeaccesstokenprovider : retrieving token https://www.linkedin.com/oauth/v2/accesstoken g.c.authorizationcodeaccesstokenprovider : encoding , sending form: {grant_type=[authorization_code], code=[xxxxxxxxxxxxxxxxxxxx], redirect_uri=[http://localhost:8080/login/linkedin]} uth2clientauthenticationprocessingfilter : authentication request failed: org.springframework.security.authentication.badcredentialsexception: not obtain access token
exception:
org.springframework.security.authentication.badcredentialsexception: not obtain access token @ org.springframework.security.oauth2.client.filter.oauth2clientauthenticationprocessingfilter.attemptauthentication(oauth2clientauthenticationprocessingfilter.java:107) ~[spring-security-oauth2-2.0.13.release.jar:na] @ org.springframework.security.web.authentication.abstractauthenticationprocessingfilter.dofilter(abstractauthenticationprocessingfilter.java:212) ~[spring-security-web-4.2.2.release.jar:4.2.2.release] @ org.springframework.web.filter.compositefilter$virtualfilterchain.dofilter(compositefilter.java:112) [spring-web-4.3.7.release.jar:4.3.7.release] @ org.springframework.web.filter.compositefilter.dofilter(compositefilter.java:73) [spring-web-4.3.7.release.jar:4.3.7.release] @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:331) [spring-security-web-4.2.2.release.jar:4.2.2.release] @ org.springframework.security.web.authentication.logout.logoutfilter.dofilter(logoutfilter.java:116) [spring-security-web-4.2.2.release.jar:4.2.2.release] @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:331) [spring-security-web-4.2.2.release.jar:4.2.2.release] @ org.springframework.security.web.csrf.csrffilter.dofilterinternal(csrffilter.java:100) [spring-security-web-4.2.2.release.jar:4.2.2.release] @ org.springframework.web.filter.onceperrequestfilter.dofilter(onceperrequestfilter.java:107) [spring-web-4.3.7.release.jar:4.3.7.release] @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:331) [spring-security-web-4.2.2.release.jar:4.2.2.release] @ org.springframework.security.web.header.headerwriterfilter.dofilterinternal(headerwriterfilter.java:64) [spring-security-web-4.2.2.release.jar:4.2.2.release] @ org.springframework.web.filter.onceperrequestfilter.dofilter(onceperrequestfilter.java:107) [spring-web-4.3.7.release.jar:4.3.7.release] @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:331) [spring-security-web-4.2.2.release.jar:4.2.2.release] @ org.springframework.security.web.context.securitycontextpersistencefilter.dofilter(securitycontextpersistencefilter.java:105) [spring-security-web-4.2.2.release.jar:4.2.2.release] @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:331) [spring-security-web-4.2.2.release.jar:4.2.2.release] @ org.springframework.security.web.context.request.async.webasyncmanagerintegrationfilter.dofilterinternal(webasyncmanagerintegrationfilter.java:56) [spring-security-web-4.2.2.release.jar:4.2.2.release] @ org.springframework.web.filter.onceperrequestfilter.dofilter(onceperrequestfilter.java:107) [spring-web-4.3.7.release.jar:4.3.7.release] @ org.springframework.security.web.filterchainproxy$virtualfilterchain.dofilter(filterchainproxy.java:331) [spring-security-web-4.2.2.release.jar:4.2.2.release] @ org.springframework.security.web.filterchainproxy.dofilterinternal(filterchainproxy.java:214) [spring-security-web-4.2.2.release.jar:4.2.2.release] @ org.springframework.security.web.filterchainproxy.dofilter(filterchainproxy.java:177) [spring-security-web-4.2.2.release.jar:4.2.2.release] @ org.springframework.web.filter.delegatingfilterproxy.invokedelegate(delegatingfilterproxy.java:346) [spring-web-4.3.7.release.jar:4.3.7.release] @ org.springframework.web.filter.delegatingfilterproxy.dofilter(delegatingfilterproxy.java:262) [spring-web-4.3.7.release.jar:4.3.7.release] @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:192) [tomcat-embed-core-8.5.11.jar:8.5.11] @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:165) [tomcat-embed-core-8.5.11.jar:8.5.11] @ org.springframework.web.filter.requestcontextfilter.dofilterinternal(requestcontextfilter.java:99) [spring-web-4.3.7.release.jar:4.3.7.release] @ org.springframework.web.filter.onceperrequestfilter.dofilter(onceperrequestfilter.java:107) [spring-web-4.3.7.release.jar:4.3.7.release] @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:192) [tomcat-embed-core-8.5.11.jar:8.5.11] @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:165) [tomcat-embed-core-8.5.11.jar:8.5.11] @ org.springframework.security.oauth2.client.filter.oauth2clientcontextfilter.dofilter(oauth2clientcontextfilter.java:60) [spring-security-oauth2-2.0.13.release.jar:na] @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:192) [tomcat-embed-core-8.5.11.jar:8.5.11] @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:165) [tomcat-embed-core-8.5.11.jar:8.5.11] @ org.springframework.web.filter.httpputformcontentfilter.dofilterinternal(httpputformcontentfilter.java:105) [spring-web-4.3.7.release.jar:4.3.7.release] @ org.springframework.web.filter.onceperrequestfilter.dofilter(onceperrequestfilter.java:107) [spring-web-4.3.7.release.jar:4.3.7.release] @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:192) [tomcat-embed-core-8.5.11.jar:8.5.11] @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:165) [tomcat-embed-core-8.5.11.jar:8.5.11] @ org.springframework.web.filter.hiddenhttpmethodfilter.dofilterinternal(hiddenhttpmethodfilter.java:81) [spring-web-4.3.7.release.jar:4.3.7.release] @ org.springframework.web.filter.onceperrequestfilter.dofilter(onceperrequestfilter.java:107) [spring-web-4.3.7.release.jar:4.3.7.release] @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:192) [tomcat-embed-core-8.5.11.jar:8.5.11] @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:165) [tomcat-embed-core-8.5.11.jar:8.5.11] @ org.springframework.web.filter.characterencodingfilter.dofilterinternal(characterencodingfilter.java:197) [spring-web-4.3.7.release.jar:4.3.7.release] @ org.springframework.web.filter.onceperrequestfilter.dofilter(onceperrequestfilter.java:107) [spring-web-4.3.7.release.jar:4.3.7.release] @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:192) [tomcat-embed-core-8.5.11.jar:8.5.11] @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:165) [tomcat-embed-core-8.5.11.jar:8.5.11] @ org.springframework.boot.actuate.autoconfigure.metricsfilter.dofilterinternal(metricsfilter.java:106) [spring-boot-actuator-1.5.2.release.jar:1.5.2.release] @ org.springframework.web.filter.onceperrequestfilter.dofilter(onceperrequestfilter.java:107) [spring-web-4.3.7.release.jar:4.3.7.release] @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:192) [tomcat-embed-core-8.5.11.jar:8.5.11] @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:165) [tomcat-embed-core-8.5.11.jar:8.5.11] @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:198) [tomcat-embed-core-8.5.11.jar:8.5.11] @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:96) [tomcat-embed-core-8.5.11.jar:8.5.11] @ org.apache.catalina.authenticator.authenticatorbase.invoke(authenticatorbase.java:474) [tomcat-embed-core-8.5.11.jar:8.5.11] @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:140) [tomcat-embed-core-8.5.11.jar:8.5.11] @ org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:79) [tomcat-embed-core-8.5.11.jar:8.5.11] @ org.apache.catalina.core.standardenginevalve.invoke(standardenginevalve.java:87) [tomcat-embed-core-8.5.11.jar:8.5.11] @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:349) [tomcat-embed-core-8.5.11.jar:8.5.11] @ org.apache.coyote.http11.http11processor.service(http11processor.java:783) [tomcat-embed-core-8.5.11.jar:8.5.11] @ org.apache.coyote.abstractprocessorlight.process(abstractprocessorlight.java:66) [tomcat-embed-core-8.5.11.jar:8.5.11] @ org.apache.coyote.abstractprotocol$connectionhandler.process(abstractprotocol.java:798) [tomcat-embed-core-8.5.11.jar:8.5.11] @ org.apache.tomcat.util.net.nioendpoint$socketprocessor.dorun(nioendpoint.java:1434) [tomcat-embed-core-8.5.11.jar:8.5.11] @ org.apache.tomcat.util.net.socketprocessorbase.run(socketprocessorbase.java:49) [tomcat-embed-core-8.5.11.jar:8.5.11] @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1149) [na:1.8.0_144] @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:624) [na:1.8.0_144] @ org.apache.tomcat.util.threads.taskthread$wrappingrunnable.run(taskthread.java:61) [tomcat-embed-core-8.5.11.jar:8.5.11] @ java.lang.thread.run(thread.java:748) [na:1.8.0_144] caused by: org.springframework.security.oauth2.client.resource.oauth2accessdeniedexception: access token denied. @ org.springframework.security.oauth2.client.token.oauth2accesstokensupport.retrievetoken(oauth2accesstokensupport.java:142) ~[spring-security-oauth2-2.0.13.release.jar:na] @ org.springframework.security.oauth2.client.token.grant.code.authorizationcodeaccesstokenprovider.obtainaccesstoken(authorizationcodeaccesstokenprovider.java:209) ~[spring-security-oauth2-2.0.13.release.jar:na] @ org.springframework.security.oauth2.client.token.accesstokenproviderchain.obtainnewaccesstokeninternal(accesstokenproviderchain.java:148) ~[spring-security-oauth2-2.0.13.release.jar:na] @ org.springframework.security.oauth2.client.token.accesstokenproviderchain.obtainaccesstoken(accesstokenproviderchain.java:121) ~[spring-security-oauth2-2.0.13.release.jar:na] @ org.springframework.security.oauth2.client.oauth2resttemplate.acquireaccesstoken(oauth2resttemplate.java:221) ~[spring-security-oauth2-2.0.13.release.jar:na] @ org.springframework.security.oauth2.client.oauth2resttemplate.getaccesstoken(oauth2resttemplate.java:173) ~[spring-security-oauth2-2.0.13.release.jar:na] @ org.springframework.security.oauth2.client.filter.oauth2clientauthenticationprocessingfilter.attemptauthentication(oauth2clientauthenticationprocessingfilter.java:105) ~[spring-security-oauth2-2.0.13.release.jar:na] ... 62 common frames omitted caused by: org.springframework.security.oauth2.common.exceptions.invalidrequestexception: required parameter "client_id" missing @ org.springframework.security.oauth2.common.exceptions.oauth2exceptionjackson2deserializer.deserialize(oauth2exceptionjackson2deserializer.java:100) ~[spring-security-oauth2-2.0.13.release.jar:na] @ org.springframework.security.oauth2.common.exceptions.oauth2exceptionjackson2deserializer.deserialize(oauth2exceptionjackson2deserializer.java:33) ~[spring-security-oauth2-2.0.13.release.jar:na] @ com.fasterxml.jackson.databind.objectmapper._readmapandclose(objectmapper.java:3798) ~[jackson-databind-2.8.7.jar:2.8.7] @ com.fasterxml.jackson.databind.objectmapper.readvalue(objectmapper.java:2922) ~[jackson-databind-2.8.7.jar:2.8.7] @ org.springframework.http.converter.json.abstractjackson2httpmessageconverter.readjavatype(abstractjackson2httpmessageconverter.java:237) ~[spring-web-4.3.7.release.jar:4.3.7.release] @ org.springframework.http.converter.json.abstractjackson2httpmessageconverter.readinternal(abstractjackson2httpmessageconverter.java:217) ~[spring-web-4.3.7.release.jar:4.3.7.release] @ org.springframework.http.converter.abstracthttpmessageconverter.read(abstracthttpmessageconverter.java:193) ~[spring-web-4.3.7.release.jar:4.3.7.release] @ org.springframework.security.oauth2.client.token.oauth2accesstokensupport$accesstokenerrorhandler.handleerror(oauth2accesstokensupport.java:235) ~[spring-security-oauth2-2.0.13.release.jar:na] @ org.springframework.web.client.resttemplate.handleresponse(resttemplate.java:700) ~[spring-web-4.3.7.release.jar:4.3.7.release] @ org.springframework.web.client.resttemplate.doexecute(resttemplate.java:653) ~[spring-web-4.3.7.release.jar:4.3.7.release] @ org.springframework.web.client.resttemplate.execute(resttemplate.java:621) ~[spring-web-4.3.7.release.jar:4.3.7.release] @ org.springframework.security.oauth2.client.token.oauth2accesstokensupport.retrievetoken(oauth2accesstokensupport.java:137) ~[spring-security-oauth2-2.0.13.release.jar:na] ... 68 common frames omitted
from "client_id" missing
error , https://developer.linkedin.com/docs/oauth2 can see need submit client_id
part of request params
and can clientauthenticationscheme: form
in config
linkedin: client: clientid: xxx clientsecret: yyy accesstokenuri: https://www.linkedin.com/oauth/v2/accesstoken userauthorizationuri: https://www.linkedin.com/oauth/v2/authorization clientauthenticationscheme: form resource: userinfouri: https://api.linkedin.com/v1/people/~?format=json
i believe default behavior submit authenticationscheme info in header
source
Comments
Post a Comment