Skip to content
This repository has been archived by the owner on Apr 5, 2022. It is now read-only.

Getting org.springframework.social.ExpiredAuthorizationException 1 min after login #229

Open
stefanicai opened this issue May 26, 2017 · 0 comments

Comments

@stefanicai
Copy link

stefanicai commented May 26, 2017

I'm trying to get the event info of the current user (user has authorised access for that), and I get org.springframework.social.ExpiredAuthorizationException: The authorization has expired. when I do fbConnection.getApi(), so it fails to get the Facebook object.

But, the same code works well right after login, just in a different part of the code. I thought that maybe the token expired, so I got a long lived one, but I get the same issue. Any idea why it works right after login, but not 5 mins later? I seem to be doing exactly the same thing in both cases.

The code that fails is:

Connection<Facebook> fbConnection = usersConnectionRepository.createConnectionRepository(loggedIn.getId().toString()).findPrimaryConnection(Facebook.class);
if (fbConnection != null) {
	Facebook facebook = fbConnection.getApi();
	org.springframework.social.facebook.api.Event ev = facebook.eventOperations().getEvent(fbEventId);
	System.out.println(ev.getDescription());
}

The configuration is in XML and looks like this:

<bean id="authenticationEntryPoint" class="org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint">
	<constructor-arg value="/login"/>
	<property name="useForward" value="true"/>
</bean>

<bean class="com.xxx.web.SpringDataUserDetailsService" id="userService"/>

<security:authentication-manager alias="authenticationManager">
	<security:authentication-provider user-service-ref="userService"/>
	<security:authentication-provider ref="socialAuthenticationProvider" />
</security:authentication-manager>

<bean class="org.springframework.social.security.SocialAuthenticationFilter" id="socialAuthenticationFilter">
	<constructor-arg ref="authenticationManager" />
	<constructor-arg ref="userIdSource" />
	<constructor-arg ref="usersConnectionRepository" />
	<constructor-arg ref="connectionRegistry" />

	<property name="postLoginUrl" value="/home" />
	<property name="defaultFailureUrl" value="/login?error&amp;social" />
	<property name="signupUrl" value="/user/signup" />
</bean>

<bean class="org.springframework.social.connect.web.ProviderSignInUtils">
	<constructor-arg ref="connectionRegistry"/>
	<constructor-arg ref="usersConnectionRepository"/>
</bean>

<bean id="userIdSource" class="org.springframework.social.security.AuthenticationNameUserIdSource" />

<bean id="socialAuthenticationProvider"
	class="org.springframework.social.security.SocialAuthenticationProvider">
	<constructor-arg ref="usersConnectionRepository" />
	<constructor-arg ref="userService" />
</bean>

<bean id="userSocialConnectionService" class="com.xxx.web.UserSocialConnectionController"></bean>

<bean id="usersConnectionRepository" class="com.xxx.social.SpringDataUsersConnectionRepository">
	<constructor-arg ref="connectionRegistry" />
</bean>

<bean id="connectionRegistry"
		class="org.springframework.social.security.SocialAuthenticationServiceRegistry">
	<property name="authenticationServices">
		<list>
			<bean class="org.springframework.social.facebook.security.FacebookAuthenticationService">
				<constructor-arg value="${facebook.app.id}" />
				<constructor-arg value="${facebook.app.secret}" />
				<constructor-arg value="${facebook.app.namespace}" />
			</bean>
		</list>
	</property>
</bean>

Any ideas? I can't seem to find any documentation online on the topic. Thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

1 participant