diff --git a/allgo/__init__.py b/allgo/__init__.py
index cfe51bba9a3b6f2481e15e58632d677bda8ddd12..16465b0e7e0ae1606770b659d974ee04715b1745 100644
--- a/allgo/__init__.py
+++ b/allgo/__init__.py
@@ -47,7 +47,7 @@ class Init:
         string
             allgo login page link or already initialized message
         """
-        if API_token is None
+        if not API_token_valid:
             API_token = get_random_string(length=32)
             msg = "allgo_token = " + API_token
             msg += "<p>Sign in with your existing <a href=\"https://allgo18.inria.fr/accounts/login/?token=" + API_token+  "\">A||GO account </a></p>"