Yammer authentication - check if token is valid

375 views Asked by At

I'm using Yammer JS SDK to authenticate users to access some web service. I'm using JS SDK to obtain a token and I store it in session. Current flow is following (may be wrong, correct me, if necessary):

  1. User accesses any page, PHP is checking for token stored in session vars. If not - user is redirected to login page
  2. Using Yammer SDK I'm getting an access token and save it to session vars (POSTing it to our server side login service) and render the requested page.

Problem so far - I can't find any way in Yammer API to check if the access token stored\passed to my web service is actually the right thing. Which means, that potentially anyone can generate some random gibberish data, use that as a token and view content - the rest of Yammer functionality will be broken, but content will be visible.
The smartest way I thought of so far is to try and get some client info from Yammer REST API using the token and if response is invalid - delete the session stored token.
How do I do that the proper way?

1

There are 1 answers

1
Peter Willsey On

Checking for HTTP status code 401 Unauthorized Access on a request is the only way I know of to determine if your Token is valid. There are a couple instances where you will get a 401 back with a valid token, but this is pretty rare.