Hi,

I'm trying to redirect a user if token doesn't exists in the 
cookie/localstorage.

I'm doing a check whether a token exist if not then redirect to 
http://authserver.webazure.net (e.g url).

if (cookieCheck == null) {
    window.location.href = 'http://authserver.webazure.net '; // redirect 
url
 } else {
  console.log('Cookie exist');
  // Omni auth
  window.swaggerUi.load();
  var apiKeyAuth = new SwaggerClient.ApiKeyAuthorization("Authorization", 
"Bearer " + $.cookie('access_token'), "header");
  window.swaggerUi.api.clientAuthorizations.add("oauth2", apiKeyAuth);
}

Setting the cookie in o2c.html

if (window.opener.swaggerUiAuth.tokenUrl) // error is here
    window.opener.processOAuthCode(qp);
  else 
    window.opener.onOAuthComplete(qp);
    var accessToken = getUrlVars('access_token');
    setCookie('access_token', accessToken)

The redirect works okay however once Iogged in and and trying to redirect 
me back to my SwaggerUI I get an error '*Cannot read property 
'swaggerUiAuth' of null'*

Does anyone know about this?

-- 
You received this message because you are subscribed to the Google Groups 
"Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to