diff --git a/src/jamidht/jamiaccount.cpp b/src/jamidht/jamiaccount.cpp
index ea9d0b10226e0c68f52ba327e38828a15f3eff6b..932e1be75220ef4d8fae535d3a80a195713a8cf4 100644
--- a/src/jamidht/jamiaccount.cpp
+++ b/src/jamidht/jamiaccount.cpp
@@ -1363,10 +1363,10 @@ JamiAccount::loadAccount(const std::string& archive_password_scheme,
                  id,
                  accountId = getAccountID(),
                  migrating](AccountManager::AuthError error, const std::string& message) {
-                    JAMI_WARN("[Account %s] Auth error: %d %s",
-                              accountId.c_str(),
+                    JAMI_WARNING("[Account {}] Auth error: {} {}",
+                              accountId,
                               (int) error,
-                              message.c_str());
+                              message);
                     if ((id.first || migrating)
                         && error == AccountManager::AuthError::INVALID_ARGUMENTS) {
                         // In cast of a migration or manager connexion failure stop the migration
@@ -1386,7 +1386,7 @@ JamiAccount::loadAccount(const std::string& archive_password_scheme,
                 callbacks);
         }
     } catch (const std::exception& e) {
-        JAMI_WARN("[Account %s] error loading account: %s", getAccountID().c_str(), e.what());
+        JAMI_WARNING("[Account {}] error loading account: {}", getAccountID(), e.what());
         accountManager_.reset();
         setRegistrationState(RegistrationState::ERROR_GENERIC);
     }
@@ -2166,6 +2166,15 @@ JamiAccount::doRegister_()
         });
 
         if (!conf.managerUri.empty() && accountManager_) {
+            dynamic_cast<ServerAccountManager*>(accountManager_.get())
+                ->onNeedsMigration([this]() {
+                    editConfig([&](JamiAccountConfig& conf) {
+                        conf.receipt.clear();
+                        conf.receiptSignature.clear();
+                    });
+                    Migration::setState(accountID_, Migration::State::INVALID);
+                    setRegistrationState(RegistrationState::ERROR_NEED_MIGRATION);
+                });
             dynamic_cast<ServerAccountManager*>(accountManager_.get())
                 ->syncBlueprintConfig([this](const std::map<std::string, std::string>& config) {
                     editConfig([&](JamiAccountConfig& conf) { conf.fromMap(config); });
diff --git a/src/jamidht/server_account_manager.cpp b/src/jamidht/server_account_manager.cpp
index db39b800648fd2cb682b4cf69749fcd714b5bf5a..d708e2d1d94040f99551c7cb55a3c86a6c0530b1 100644
--- a/src/jamidht/server_account_manager.cpp
+++ b/src/jamidht/server_account_manager.cpp
@@ -103,13 +103,13 @@ ServerAccountManager::initAuthentication(const std::string& accountId,
             url,
             body,
             [ctx, w](Json::Value json, const dht::http::Response& response) {
-                JAMI_DBG("[Auth] Got request callback with status code=%u",
-                            response.status_code);
+                JAMI_DEBUG("[Auth] Got request callback with status code={} {}",
+                            response.status_code, response.body);
                 auto this_ = std::static_pointer_cast<ServerAccountManager>(w.lock());
                 if (response.status_code == 0 || this_ == nullptr)
                     ctx->onFailure(AuthError::SERVER_ERROR, "Can't connect to server");
                 else if (response.status_code >= 400 && response.status_code < 500)
-                    ctx->onFailure(AuthError::INVALID_ARGUMENTS, "");
+                    ctx->onFailure(AuthError::INVALID_ARGUMENTS, "Invalid credentials provided!");
                 else if (response.status_code < 200 || response.status_code > 299)
                     ctx->onFailure(AuthError::INVALID_ARGUMENTS, "");
                 else {
@@ -223,9 +223,10 @@ ServerAccountManager::onAuthEnded(const Json::Value& json,
                          : (scopeStr == "USER"sv ? TokenScope::User : TokenScope::None);
         auto expires_in = json["expires_in"].asLargestUInt();
         auto expiration = std::chrono::steady_clock::now() + std::chrono::seconds(expires_in);
-        JAMI_WARN("[Auth] Got server response: %d %s", response.status_code, response.body.c_str());
+        JAMI_WARNING("[Auth] Got server response: {} {}", response.status_code, response.body);
         setToken(json["access_token"].asString(), scope, expiration);
     } else {
+        JAMI_WARNING("[Auth] Got server response: {} {}", response.status_code, response.body);
         authFailed(expectedScope, response.status_code);
     }
     clearRequest(response.request);
@@ -299,9 +300,16 @@ ServerAccountManager::authFailed(TokenScope scope, int code)
         std::lock_guard lock(tokenLock_);
         requests = std::move(getRequestQueue(scope));
     }
-    JAMI_DBG("[Auth] Failed auth with scope %d, ending %zu pending requests",
+    JAMI_DEBUG("[Auth] Failed auth with scope {}, ending {} pending requests",
              (int) scope,
              requests.size());
+    if (code == 401) {
+        // NOTE: we do not login every time to the server but retrieve a device token to use the account
+        // If authentificate device fails with 401
+        // it means that the device is revoked
+        if (onNeedsMigration_)
+            onNeedsMigration_();
+    }
     while (not requests.empty()) {
         auto req = std::move(requests.front());
         requests.pop();
diff --git a/src/jamidht/server_account_manager.h b/src/jamidht/server_account_manager.h
index 497c3a418f14512ebdb7f15550fb98f68883036f..df93bafc47eae236be58ad04471c9ab794f3a715 100644
--- a/src/jamidht/server_account_manager.h
+++ b/src/jamidht/server_account_manager.h
@@ -68,6 +68,10 @@ public:
                       std::string_view scheme, const std::string& password,
                       RegistrationCallback cb) override;
 
+    void onNeedsMigration(std::function<void()> cb) {
+        onNeedsMigration_ = std::move(cb);
+    }
+
 private:
     struct AuthContext
     {
@@ -120,6 +124,7 @@ private:
     void authFailed(TokenScope scope, int code);
     void authError(TokenScope scope);
     void onAuthEnded(const Json::Value& json, const dht::http::Response& response, TokenScope scope);
+    std::function<void()> onNeedsMigration_;
 
     void setToken(std::string token,
                   TokenScope scope,