when call yam.platform.getloginstatus right after logging in using yam.platform.login (shows popup etc.) different object passed callback when user logged in. specifically, 'user' field missing on loginstatus response object, otherwise looks same far can see.
i have following controller 'login yammer' area on angular app:
function yammerlogincontroller($scope, $compile) { $scope.isloggedin = false; $scope.username = "-"; $scope.login = function () { yam.platform.login(function (response) { if (response.authresponse) { console.log("logged in"); } refreshloginstatus(); }); } refreshloginstatus(); // initialize values function refreshloginstatus() { yam.getloginstatus(function (response) { console.dir(response); if (response.authresponse) { if (response.user) { console.log("yammerlogin: logged in " + response.user.full_name); console.dir(response); $scope.$apply(function () { $scope.isloggedin = true; $scope.username = response.user.full_name; }); } else { console.log("wtf yammer api!"); // happens. } } else { console.log("yammerlogin: not logged in."); $('#loggedinview').popover("hide"); $scope.$apply(function () { $scope.isloggedin = false; $scope.username = "-"; }); } }); } when controller created queries current login status using refreshloginstatus function. if yammer user logged in app display user name , logout button on page (done ng-show="isloggedin"). if user not logged in, login button shown instead. when user clicks on login button, $scope.login function called, invoking yam.platform.login and, if successful, calls refreshloginstatus again in order retrieve , set user's name. in scenario, object returned both, login , getloginstatus not contain user information in 'user logged in' scenario. tried calling sdk-api again after timeout, apparently response cached - same. refreshing whole page clears out current response, querying status again , receiving 'complete' response object.
i thought scoping problem, i'm not sure whether it's problem in sdk itself. :s
edit: kind of found solution, gives me worse problems. apparently request indeed cached. refresh can forced using 'force refresh' on yam.platform.getloginstatus(callback, [forcerefresh]). this, gives me following error on browser console:
xmlhttprequest cannot load https://www.yammer.com/platform/login_status.json?client_id=2h4u2hndg5kdwq8xxxxxx. no 'access-control-allow-origin' header present on requested resource. origin 'http://localhost:9000' therefore not allowed access.
basically, sdk fails getloginstatus, completely, , reports code 'no connection'. i'm not sure what's worse... or, doing wrong?
it appears inconsistency in yam.platform.getloginstatus api or corresponding yammer service called. if user logs in, user info, if alreaddy logged in, don't it. weird apparently can't helped.
however, solved problem getting user login data using separate rest service call on /users/current.json once session authenticated (once have token getloginstatus).
Comments
Post a Comment