View Full Version : 401 on receipt of token. What am I missing?
Mar 29th, 2011, 07:42 PM
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!
Mar 30th, 2011, 08:50 AM
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-showcase/connect/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?
Mar 30th, 2011, 02:32 PM
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!
Mar 31st, 2011, 07:59 AM
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.
Apr 14th, 2011, 04:28 AM
Thanks for sharing.
Powered by vBulletin® Version 4.2.1 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.