Announcement Announcement Module
Collapse
No announcement yet.
401 on receipt of token. What am I missing? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 401 on receipt of token. What am I missing?

    I'm encountering a problem wherein I receive a 401 - Not authorized error when receiving a Gowalla oauth token using the ConnectController. I've verified that I am, in fact, receiving back a token by setting a breakpoint in the Oauth2Template where it executes the RestTemplate's postForObject method and visually inspecting the response.

    My two assumptions were that:

    1. The ConnectController would persist the connection in the connection table
    2. I would be redirected to the connect/gowallaConnected view (which I defined).

    What am I missing? What is the next step?

    Thanks in advance for your help!

  • #2
    I can't say for sure what might be going wrong, but here are a few things to double-check:

    - Make sure you have configured a GowallaServiceProvider bean and are setting its API key and secret correctly in the 1st two constructor arguments.
    - Make sure that your application registration entry (on Gowalla.com) has an OAuth callback URL that matches your app configuration (http://localhost:8080/spring-social-...onnect/gowalla, for instance).

    What I'm unclear on is when you get the 401: Are you getting the 401 when you exchange the authorization code for an access token (sounds like not, since your debugging verifies that you receive an access token at that step)? Or are you getting a 401 when attempting to make calls against GowallaApi?

    Comment


    • #3
      My Token Spoiled

      I stepped more carefully through the code and noticed it bombing when it tried to get my Gowalla profile information (i.e. when I tried to interact with the API, as you suspected). Taking a closer look at the response, I notice that my access token has expired. I have to figure out how to refresh it, it seems. Is there a convenient way to do this in Spring Social? Either way, thanks for your help!

      Comment


      • #4
        Ah, an expired access token. Since this is Gowalla, that tells me that your token is about a week old. M2 doesn't have anything to enable token refreshes, but we're aiming to add in access token refreshes in M3.

        Comment


        • #5
          Thanks for sharing.

          Comment

          Working...
          X