Announcement Announcement Module
Collapse
No announcement yet.
What is the best way to check if user is connected to particular provider ? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • What is the best way to check if user is connected to particular provider ?

    Hi
    like in the topic, namely what is the best way to check if user is connected to e.g. Facebook ?
    • Code:
      ApiBinding.isAuthorized()
      - when user is not connected throws NotConnectedException (at least in case of Facebook api); do not want to use exceptions to flow control
    • Code:
      ConnectionRepository.findConnection(provider)
      - does more than simple "isConnected" and requires injection of bean, that seems to be pretty "internal"

    Hope that answer is pretty straightforward and I simply missed something obvious in docs.

    Lukas

  • #2
    The ApiBinding.isAuthorized() only checks to see if the API binding was created with an access token. Depending on your definition of "connection", a connection may or may not have been created. A FacebookTemplate, for instance, may have been created with a known access token even if no actual Connection were created and stored in the repository.

    The ConnectionRepository.findConnection() method is the best way and is not intended to be "internal" as you suggest. In fact, have a look at Spring Social Showcase in the ConnectedToHandlerInterceptor. That interceptor uses ConnectionRepository.findConnection() to determine whether or not the user is connected to Twitter and/or Facebook.

    Comment

    Working...
    X