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

Problem: An active access token must be used to query information about the current user #239

Open
Aurusd opened this issue Aug 14, 2017 · 5 comments

Comments

@Aurusd
Copy link

Aurusd commented Aug 14, 2017

Try to post message on facebook. Use for start this link http://docs.spring.io/spring-social-facebook/docs/3.0.x/reference/htmlsingle/#posting-to-and-reading-feeds
Use this code for simple test (before register myapp on developers.facebook, get valid token)
String appId = "1507175062679391";
String appSecret = "281a84481098cab1500277915caa6c76";
OAuth2Operations oauth = new FacebookConnectionFactory(appId, appSecret).getOAuthOperations();

String appToken = oauth.authenticateClient().getAccessToken();
Facebook facebook = new FacebookTemplate(appToken);
facebook.feedOperations().updateStatus("I'm trying out Spring Social!");
Have next stack trace (exception on the last line code)

14-Aug-2017 10:12:00.252 SEVERE [http-nio-8080-exec-2] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [mvc-dispatcher] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.social.ResourceNotFoundException: An active access token must be used to query information about the current user.] with root cause
org.springframework.social.ResourceNotFoundException: An active access token must be used to query information about the current user.

Spring version: 4.3.7; social-core: 1.1.4.RELEASE; spring-social-facebook: 2.0.3.RELEASE
Can someone explain what i missed?

@AndriyBrez
Copy link

Hi @Aurusd, First of all currently update status operation from the application is forbidden. You can read the only user public information like 'user name' ext. An error from Facebook means that you must specify userId instead of using default "me" userId which used in method updateStatus . For example:

@RunWith(SpringRunner.class)
@SpringBootTest
public class FacebookTests {
	@Value("${spring.social.facebook.appId}")
	private String appId;
	@Value("${spring.social.facebook.appSecret}")
	private String appSecret;
	@Test
	public void shouldFatchFacebookUserNameById() {
		OAuth2Operations oauth = new FacebookConnectionFactory(appId, appSecret).getOAuthOperations();
		String appToken = oauth.authenticateClient().getAccessToken();
		Facebook facebook = new FacebookTemplate(appToken);
		String markZuckerbergFacebookId = "4";
		User user = facebook.fetchObject(markZuckerbergFacebookId, User.class);
		assertEquals("Mark Zuckerberg", user.getName());
	}
}

@Aurusd
Copy link
Author

Aurusd commented Sep 13, 2017

almost month i am waiting for some answer))

@Aurusd
Copy link
Author

Aurusd commented Sep 13, 2017

Where i can get example code for post something on my facebook page with using spring-social? Or at least can you give some resource where i can find it?

@Aurusd
Copy link
Author

Aurusd commented Sep 13, 2017

How i can get user id facebook? via user authorization or another way? Maybe you provide some code for authorization via spring social?

@AndriyBrez
Copy link

Please look deeply in https://developers.facebook.com/docs/graph-api/ as I know spring social doesn't support new API v2.10

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

2 participants