org.springframework.social.NotAuthorizedException: Invalid access token.

Spring JIRA | Sylvain Senechal | 3 years ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    If i use : LinkedInConnectionFactory ln = new LinkedInConnectionFactory(APP_ID, APP_SECRET); AccessGrant accessGrant = new AccessGrant(MY_ACCESS_TOKEN); Connection<LinkedIn> connection = ln.createConnection(accessGrant); I got : 29 nov. 2013 17:49:14 org.springframework.web.client.RestTemplate handleResponseError ATTENTION: GET request for "https://api.linkedin.com/v1/people/~:(id,first-name,last-name,emailAddress,headline,industry,site-standard-profile-request,public-profile-url,picture-url,summary)?format=json" resulted in 401 (Unauthorized); invoking error handler Exception in thread "main" org.springframework.social.NotAuthorizedException: Invalid access token. at org.springframework.social.linkedin.api.impl.LinkedInErrorHandler.handleError(LinkedInErrorHandler.java:44) at org.springframework.web.client.RestTemplate.handleResponseError(RestTemplate.java:537) at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:493) at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:465) at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:236) at org.springframework.social.linkedin.api.impl.ProfileTemplate.getUserProfile(ProfileTemplate.java:123) at org.springframework.social.linkedin.api.impl.ProfileTemplate.getUserProfile(ProfileTemplate.java:88) at org.springframework.social.linkedin.connect.LinkedInAdapter.setConnectionValues(LinkedInAdapter.java:43) at org.springframework.social.linkedin.connect.LinkedInAdapter.setConnectionValues(LinkedInAdapter.java:30) at org.springframework.social.connect.support.AbstractConnection.setValues(AbstractConnection.java:172) at org.springframework.social.connect.support.AbstractConnection.initKey(AbstractConnection.java:135) at org.springframework.social.connect.support.OAuth2Connection.<init>(OAuth2Connection.java:73) at org.springframework.social.connect.support.OAuth2ConnectionFactory.createConnection(OAuth2ConnectionFactory.java:91) if i use : LinkedIn template = new LinkedInTemplate(MY_ACCESS_TOKEN); List<LinkedInProfile> connections = template.connectionOperations().getConnections(); for (LinkedInProfile linkedInProfile : connections) { System.out.println(linkedInProfile.getSummary()); } I got (i got the connection , without APP_ID, APP_SECRET) 29 nov. 2013 17:53:57 org.springframework.web.client.RestTemplate handleResponseError ATTENTION: GET request for "https://api.linkedin.com/v1/people/~/connections?format=json" resulted in 401 (Unauthorized); invoking error handler Exception in thread "main" org.springframework.social.NotAuthorizedException: Invalid access token. at org.springframework.social.linkedin.api.impl.LinkedInErrorHandler.handleError(LinkedInErrorHandler.java:44) at org.springframework.web.client.RestTemplate.handleResponseError(RestTemplate.java:537) at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:493) at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:465) at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:236) at org.springframework.social.linkedin.api.impl.ConnectionTemplate.getConnections(ConnectionTemplate.java:44)

    Spring JIRA | 3 years ago | Sylvain Senechal
    org.springframework.social.NotAuthorizedException: Invalid access token.
  2. 0

    If i use : LinkedInConnectionFactory ln = new LinkedInConnectionFactory(APP_ID, APP_SECRET); AccessGrant accessGrant = new AccessGrant(MY_ACCESS_TOKEN); Connection<LinkedIn> connection = ln.createConnection(accessGrant); I got : 29 nov. 2013 17:49:14 org.springframework.web.client.RestTemplate handleResponseError ATTENTION: GET request for "https://api.linkedin.com/v1/people/~:(id,first-name,last-name,emailAddress,headline,industry,site-standard-profile-request,public-profile-url,picture-url,summary)?format=json" resulted in 401 (Unauthorized); invoking error handler Exception in thread "main" org.springframework.social.NotAuthorizedException: Invalid access token. at org.springframework.social.linkedin.api.impl.LinkedInErrorHandler.handleError(LinkedInErrorHandler.java:44) at org.springframework.web.client.RestTemplate.handleResponseError(RestTemplate.java:537) at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:493) at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:465) at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:236) at org.springframework.social.linkedin.api.impl.ProfileTemplate.getUserProfile(ProfileTemplate.java:123) at org.springframework.social.linkedin.api.impl.ProfileTemplate.getUserProfile(ProfileTemplate.java:88) at org.springframework.social.linkedin.connect.LinkedInAdapter.setConnectionValues(LinkedInAdapter.java:43) at org.springframework.social.linkedin.connect.LinkedInAdapter.setConnectionValues(LinkedInAdapter.java:30) at org.springframework.social.connect.support.AbstractConnection.setValues(AbstractConnection.java:172) at org.springframework.social.connect.support.AbstractConnection.initKey(AbstractConnection.java:135) at org.springframework.social.connect.support.OAuth2Connection.<init>(OAuth2Connection.java:73) at org.springframework.social.connect.support.OAuth2ConnectionFactory.createConnection(OAuth2ConnectionFactory.java:91) if i use : LinkedIn template = new LinkedInTemplate(MY_ACCESS_TOKEN); List<LinkedInProfile> connections = template.connectionOperations().getConnections(); for (LinkedInProfile linkedInProfile : connections) { System.out.println(linkedInProfile.getSummary()); } I got (i got the connection , without APP_ID, APP_SECRET) 29 nov. 2013 17:53:57 org.springframework.web.client.RestTemplate handleResponseError ATTENTION: GET request for "https://api.linkedin.com/v1/people/~/connections?format=json" resulted in 401 (Unauthorized); invoking error handler Exception in thread "main" org.springframework.social.NotAuthorizedException: Invalid access token. at org.springframework.social.linkedin.api.impl.LinkedInErrorHandler.handleError(LinkedInErrorHandler.java:44) at org.springframework.web.client.RestTemplate.handleResponseError(RestTemplate.java:537) at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:493) at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:465) at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:236) at org.springframework.social.linkedin.api.impl.ConnectionTemplate.getConnections(ConnectionTemplate.java:44)

    Spring JIRA | 3 years ago | Sylvain Senechal
    org.springframework.social.NotAuthorizedException: Invalid access token.

    Root Cause Analysis

    1. org.springframework.social.NotAuthorizedException

      Invalid access token.

      at org.springframework.social.linkedin.api.impl.LinkedInErrorHandler.handleError()
    2. LinkedIn API
      LinkedInErrorHandler.handleError
      1. org.springframework.social.linkedin.api.impl.LinkedInErrorHandler.handleError(LinkedInErrorHandler.java:44)
      1 frame
    3. Spring
      RestTemplate.getForObject
      1. org.springframework.web.client.RestTemplate.handleResponseError(RestTemplate.java:537)
      2. org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:493)
      3. org.springframework.web.client.RestTemplate.execute(RestTemplate.java:465)
      4. org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:236)
      4 frames
    4. LinkedIn API
      LinkedInAdapter.setConnectionValues
      1. org.springframework.social.linkedin.api.impl.ProfileTemplate.getUserProfile(ProfileTemplate.java:123)
      2. org.springframework.social.linkedin.api.impl.ProfileTemplate.getUserProfile(ProfileTemplate.java:88)
      3. org.springframework.social.linkedin.connect.LinkedInAdapter.setConnectionValues(LinkedInAdapter.java:43)
      4. org.springframework.social.linkedin.connect.LinkedInAdapter.setConnectionValues(LinkedInAdapter.java:30)
      4 frames
    5. Foundational module containing the ServiceProvider Connect Framework and Service API invocation support.
      OAuth2ConnectionFactory.createConnection
      1. org.springframework.social.connect.support.AbstractConnection.setValues(AbstractConnection.java:172)
      2. org.springframework.social.connect.support.AbstractConnection.initKey(AbstractConnection.java:135)
      3. org.springframework.social.connect.support.OAuth2Connection.<init>(OAuth2Connection.java:73)
      4. org.springframework.social.connect.support.OAuth2ConnectionFactory.createConnection(OAuth2ConnectionFactory.java:91)
      4 frames