From 6f17ad7685d98f9368bb1713b669c3413138507d Mon Sep 17 00:00:00 2001 From: Jeff Davis Date: Wed, 29 Jul 2015 15:07:57 -0700 Subject: [PATCH] Check for session token before accessing Library Account API This prevents a 404 error which can cause an "Authentication Required" popup to appear in Chrome. Signed-off-by: Jeff Davis --- src/od_api.coffee | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/od_api.coffee b/src/od_api.coffee index 7811f4c..a300c16 100644 --- a/src/od_api.coffee +++ b/src/od_api.coffee @@ -214,7 +214,15 @@ define [ # apiLibraryInfo: -> - get = -> od.api session.links.libraries.href + get = -> + if session.token.token_type? + od.api session.links.libraries.href + else + # We have no token of either kind. Let's default to getting + # a library access token. + od.apiDiscAccess() + .then get, logError + .then ok ok = (x) -> session.links.update x -- 2.11.0