skype4pidgin icon indicating copy to clipboard operation
skype4pidgin copied to clipboard

Failed getting Registration Token error.

Open Zombie-Ryushu opened this issue 8 months ago • 24 comments

Failed getting Registration Token error. This just started this morning.

Zombie-Ryushu avatar Mar 12 '25 15:03 Zombie-Ryushu

They're actively changing API for ongoing migration to Teams. At least it looks like client-s.gateway.messenger.live.com became msgapi.teams.live.com, I'm not sure whether the argument format is the same.

Nable80 avatar Mar 12 '25 18:03 Nable80

I found that out. I'm changing my Skype accounts to Teams Currently. The issue becomes I don't know how to perform a Teams login with Spectrum 2.

Zombie-Ryushu avatar Mar 12 '25 18:03 Zombie-Ryushu

I've been working on a Teams plugin at https://github.com/EionRobb/purple-teams

I'm surprised they're transitioning everyone over rather than close it off completely, but makes sense.

EionRobb avatar Mar 12 '25 18:03 EionRobb

This is happening to me too. Is there anything that I can do to continue to use skype on pidgin until all my contacts can be moved from skype to teams (which skype has said will take awhile)?

Alli1259 avatar Mar 12 '25 20:03 Alli1259

@Alli1259 you can try to reverse-engineer the API changes (it looks like there aren't many of them yet but I haven't figured them all and it'll take some time for me to learn how to debug pidgin plugins, especially the HTTP requests' stuff) and update the code accordingly. It doesn't look like there's an easy way.

Nable80 avatar Mar 15 '25 12:03 Nable80

this could help someone: https://github.com/miranda-ng/miranda-ng/commit/f5af0de316fc2701511beb413ae37cb612af24e0

peci1 avatar Mar 20 '25 15:03 peci1

I also discovered this bug a few days ago.

I hope someone will be able to make a PR with the modifications indicated by @peci1

I tried to see if I could adapt it myself but the codes are too different :( and as I expected just changing the api endpoint obviously doesn't work

jeremyp3 avatar Mar 20 '25 18:03 jeremyp3

@peci1 wow, you're awesome. At least I got some latest messages (not all of them and without proper sorting, of course, it's an old known bug of this particular plugin but that's irrelevant for now) after these changes:

diff --git a/skypeweb/libskypeweb.c b/skypeweb/libskypeweb.c
index 04ad7ac..fb6a76c 100644
--- a/skypeweb/libskypeweb.c
+++ b/skypeweb/libskypeweb.c
@@ -26,7 +26,9 @@
 void
 skypeweb_do_all_the_things(SkypeWebAccount *sa)
 {
+#if 0
 	skypeweb_get_vdms_token(sa);
+#endif
 
 	if (!sa->username) {
 		skypeweb_get_self_details(sa);
diff --git a/skypeweb/libskypeweb.h b/skypeweb/libskypeweb.h
index 788a97c..962c57e 100644
--- a/skypeweb/libskypeweb.h
+++ b/skypeweb/libskypeweb.h
@@ -119,7 +119,7 @@
 
 #define SKYPEWEB_CONTACTS_HOST "api.skype.com"
 #define SKYPEWEB_NEW_CONTACTS_HOST "contacts.skype.com"
-#define SKYPEWEB_DEFAULT_MESSAGES_HOST "client-s.gateway.messenger.live.com"
+#define SKYPEWEB_DEFAULT_MESSAGES_HOST "msgapi.teams.live.com"
 #define SKYPEWEB_LOGIN_HOST "login.skype.com"
 #define SKYPEWEB_VIDEOMAIL_HOST "vm.skype.com"
 #define SKYPEWEB_XFER_HOST "api.asm.skype.com"
diff --git a/skypeweb/skypeweb_connection.c b/skypeweb/skypeweb_connection.c
index 0ff4109..0ed661b 100644
--- a/skypeweb/skypeweb_connection.c
+++ b/skypeweb/skypeweb_connection.c
@@ -114,14 +114,15 @@ SkypeWebConnection *skypeweb_post_or_get(SkypeWebAccount *sa, SkypeWebMethod met
 		purple_http_request_header_set(request, "X-Stratus-Caller", SKYPEWEB_CLIENTINFO_NAME);
 		purple_http_request_header_set(request, "X-Stratus-Request", "abcd1234");
 		purple_http_request_header_set(request, "Origin", "https://web.skype.com");
-		purple_http_request_header_set(request, "Referer", "https://web.skype.com/main");
+		purple_http_request_header_set(request, "Referer", "https://web.skype.com/");
 		purple_http_request_header_set(request, "Accept", "application/json; ver=1.0;");
 	} else if (g_str_equal(host, SKYPEWEB_GRAPH_HOST)) {
 		purple_http_request_header_set(request, "X-Skypetoken", sa->skype_token);
 		purple_http_request_header_set(request, "Accept", "application/json");
 	} else if (g_str_equal(host, sa->messages_host)) {
 		purple_http_request_header_set(request, "RegistrationToken", sa->registration_token);
-		purple_http_request_header_set(request, "Referer", "https://web.skype.com/main");
+		purple_http_request_header_set(request, "Origin", "https://web.skype.com");
+		purple_http_request_header_set(request, "Referer", "https://web.skype.com/");
 		purple_http_request_header_set(request, "Accept", "application/json; ver=1.0");
 		purple_http_request_header_set(request, "ClientInfo", "os=Windows; osVer=8.1; proc=Win32; lcid=en-us; deviceType=1; country=n/a; clientName=" SKYPEWEB_CLIENTINFO_NAME "; clientVer=" SKYPEWEB_CLIENTINFO_VERSION);
 	} else if (g_str_equal(host, SKYPEWEB_DEFAULT_CONTACT_SUGGESTIONS_HOST)) {
@@ -148,6 +149,7 @@ SkypeWebConnection *skypeweb_post_or_get(SkypeWebAccount *sa, SkypeWebMethod met
 	conn->url = real_url;
 	conn->callback = callback_func;
 	
+	purple_http_request_header_set(request, "MS-IC3-Product", "Sfl");
 	conn->http_conn = purple_http_request(sa->pc, request, skypeweb_post_or_get_cb, conn);
 	purple_http_connection_set_add(sa->conns, conn->http_conn);
 	
diff --git a/skypeweb/skypeweb_messages.c b/skypeweb/skypeweb_messages.c
index 4acca45..903b8a7 100644
--- a/skypeweb/skypeweb_messages.c
+++ b/skypeweb/skypeweb_messages.c
@@ -720,9 +720,11 @@ skypeweb_poll_cb(SkypeWebAccount *sa, JsonNode *node, gpointer user_data)
 	JsonObject *obj = NULL;
 	
 
+#if 0
 	if (((int)time(NULL)) > sa->vdms_expiry) {
 		skypeweb_get_vdms_token(sa);
 	}
+#endif
 
 	if (node == NULL && ((int)time(NULL)) > sa->registration_expiry) {
 		skypeweb_get_registration_token(sa);
@@ -1331,8 +1333,11 @@ skypeweb_get_registration_token(SkypeWebAccount *sa)
 	purple_http_request_header_set_printf(request, "LockAndKey", "appId=" SKYPEWEB_LOCKANDKEY_APPID "; time=%s; lockAndKeyResponse=%s", curtime, response);
 	purple_http_request_header_set(request, "ClientInfo", "os=Windows; osVer=8.1; proc=Win32; lcid=en-us; deviceType=1; country=n/a; clientName=" SKYPEWEB_CLIENTINFO_NAME "; clientVer=" SKYPEWEB_CLIENTINFO_VERSION);
 	purple_http_request_header_set(request, "Content-Type", "application/json");
+	purple_http_request_header_set(request, "Origin", "https://web.skype.com");
+	purple_http_request_header_set(request, "Referer", "https://web.skype.com/");
+	purple_http_request_header_set(request, "MS-IC3-Product", "Sfl");
 	purple_http_request_header_set_printf(request, "Authentication", "skypetoken=%s", sa->skype_token);
-	purple_http_request_set_contents(request, "{\"endpointFeatures\":\"Agent\"}", -1);
+	purple_http_request_set_contents(request, "{\"endpointFeatures\":\"Agent,Presence2015,MessageProperties,CustomUserProperties,Casts,ModernBots,AutoIdleForWebApi,secureThreads,notificationStream,InviteFree,SupportsReadReceipts,ued\"}", -1);
 	purple_http_request(sa->pc, request, skypeweb_got_registration_token, sa);
 	purple_http_request_unref(request);	

I'm not sure whether all these changes are really required, it was just a mechanical port without much thinking.

Still struggling with these endless failed requests:

skypeweb: executing callback for https://contacts.skype.com/contacts/v2/users/SELF/invites
http: Performing new request 0x(ptr) to msgapi.teams.live.com.
http: Request 0x(ptr)performed without success.
skypeweb: executing callback for https://msgapi.teams.live.com/v1/users/ME/endpoints/SELF/subscriptions/0/poll
http: Performing new request 0x(ptr) to msgapi.teams.live.com.
http: Request 0x(ptr) performed without success.

Well, I should learn how to properly dump http requests/responses in pidgin but I still didn't find any time for this.

I guess /invites should go to https://edge.skype.com/pcs instead of https://contacts.skype.com (I see it in browser logs) and .../poll is a deprecated endpoint, so further progress won't be that easy. Beware, don't get banned, this patch is incomplete and pidgin floods the server with retries for now!

Nable80 avatar Mar 20 '25 23:03 Nable80

FYI: MS messed up some update yesterday and web.skype.com showed only the dialpad for a few minutes (few tens of minutes?). Browser page reload didn't help with WebUI, the broken UI loaded again and again. So I tried running pidgin with the above patch and I both received older messages and even successfully sent some newer ones, there were no errors in debug window for some time. Maybe .../poll endpoint isn't deprecated, it's just some token which isn't refreshed properly. Still no time to study the implementation in Miranda...

Nable80 avatar Mar 25 '25 09:03 Nable80

Oh, so you were the one who broke Skype. I also had only the dial pad for 15-20 minutes. Btw your patch works! Connected to skype again.

zod6 avatar Mar 27 '25 08:03 zod6

@Nable80 would be great if you could make a PR 🙂

Apparently things aren't quite ready in the Teams plugin for the Skype transition

EionRobb avatar Mar 27 '25 08:03 EionRobb

Oh, so you were the one who broke Skype.

Wut? I'm not affiliated with MS. I guess it was a joke but the situation is sad for me.

would be great if you could make a PR

The patch is incomplete and I'm afraid about complaints and possible bans due to mishandled failures of poll request. I guess it's still better than nothing, though. I'll check what I can do.

Nable80 avatar Mar 27 '25 20:03 Nable80

If anyone wants to debug this plugin (at least as much as I do), here you go:

diff --git a/skypeweb/skypeweb_connection.c b/skypeweb/skypeweb_connection.c
index 0ff4109..fb1d505 100644
--- a/skypeweb/skypeweb_connection.c
+++ b/skypeweb/skypeweb_connection.c
@@ -34,6 +34,13 @@ skypeweb_post_or_get_cb(PurpleHttpConnection *http_conn, PurpleHttpResponse *res
        const gchar *data;
        gsize len;
        
+       const GList *hdr = purple_http_response_get_all_headers(response);
+       while (hdr) {
+               PurpleKeyValuePair *kvp = hdr->data;
+               hdr = g_list_next(hdr);
+               purple_debug_info("skypeweb-response-hdr", "%s: %s\n", kvp->key, (const gchar *)kvp->value);
+       }
+
        data = purple_http_response_get_data(response, &len);
        
        if (conn->callback != NULL) {
@@ -43,6 +50,7 @@ skypeweb_post_or_get_cb(PurpleHttpConnection *http_conn, PurpleHttpResponse *res
                        conn->callback(conn->sa, NULL, conn->user_data);
                } else {
                        JsonParser *parser = json_parser_new();
+                       purple_debug_info("skypeweb", "response-body: %.*s\n", len, data);
                        if (!json_parser_load_from_data(parser, data, len, NULL))
                        {
                                if (conn->error_callback != NULL) {

When something isn't right, server replies contain quite verbose error messages with hints. That's pretty, I can finally see the difference between the normal operation and situations when /poll goes wild. In both cases you get http: Request 0x(ptr) performed without success but headers and behavior are different.

Nable80 avatar Apr 03 '25 01:04 Nable80

When your peer texts you via Teams, messages have RichText/Html messagetype instead of RichText and this plugin just dropped them before with this error message: skypeweb: Unhandled message resource messagetype 'RichText/Html'.

Use this patch to handle them instead of dropping, I just tested it and it worked for me:

--- a/skypeweb/skypeweb_messages.c
+++ b/skypeweb/skypeweb_messages.c
@@ -238,7 +238,7 @@ process_message_resource(SkypeWebAccount *sa, JsonObject *resource)
                                //purple_timeout_add_seconds(7, skypeweb_clear_typing_hack, cb);
                        }

-               } else if ((g_str_equal(messagetype, "RichText") || g_str_equal(messagetype, "Text"))) {
+               } else if (g_str_equal(messagetype, "RichText/Html") || g_str_equal(messagetype, "RichText") || g_str_equal(messagetype, "Text")) {
                        gchar *html;
                        gint64 skypeemoteoffset = 0;
                        PurpleChatUserFlags cbflags;
@@ -383,7 +383,7 @@ process_message_resource(SkypeWebAccount *sa, JsonObject *resource)
                        } else if (g_str_equal(messagetype_parts[1], "Typing")) {
                                purple_serv_got_typing(sa->pc, from, 7, PURPLE_IM_TYPING);
                        }
-               } else if ((g_str_equal(messagetype, "RichText") || g_str_equal(messagetype, "Text")) && content && *content) {
+               } else if ((g_str_equal(messagetype, "RichText/Html") || g_str_equal(messagetype, "RichText") || g_str_equal(messagetype, "Text")) && content && *content) {
                        gchar *html;
                        gint64 skypeemoteoffset = 0;
                        PurpleIMConversation *imconv;

I think image and URL messages' formats were altered in some way too (even web.skype.com handles them slightly incorrect) but I didn't debug this part yet. If anyone still uses this plugin (at least for message archival purposes, like I do) and want a proper PR, you can help with proper debugging.

Nable80 avatar Apr 05 '25 13:04 Nable80

Is this still an ongoing thing?

Zombie-Ryushu avatar Apr 10 '25 05:04 Zombie-Ryushu

Well, yes. Although these patches allowed me to receive and send messages, at some moment .../poll endpoint still starts failing with the same error reply which I mentioned earlier and still didn't invest enough time into finding how to properly handle it:

{
   "errorCode" : 404,
   "message" : "{\"errorCode\":729,\"message\":\"You must create an endpoint before performing this operation.\"}",
   "standardizedError" : {
      "errorCode" : 404,
      "errorDescription" : "{\"errorCode\":729,\"message\":\"You must create an endpoint before performing this operation.\"}",
      "errorSubCode" : 1
   }
}

I guess I should refresh some token when I receive this reply but I don't know how exactly I should handle it and nobody else is sharing their debugging sessions. Closing and opening pidgin again, well, temporary resolves this issue… for another few minutes, maybe 2 hours at best but it's not acceptable. I feel like I'm very close to the solution but my usual work is quite far from writing code, after all.

Nable80 avatar Apr 11 '25 00:04 Nable80

For those who are still using this plugin: I got a new error today, skypeweb: Full skypetoken response: {"status":{"code":50001,"text":"Unable to get mapping for a Skype user."}} but it went away after opening web interface. I don't know whether it was a temporary failure on MS side or another part of API changes was merged.

Nable80 avatar Apr 21 '25 21:04 Nable80

To the best of my knowledge nobody can use this plugin right now. At least I can't.

Zombie-Ryushu avatar Apr 21 '25 21:04 Zombie-Ryushu

You can use it (to some degree) if you apply the patches I posted above. That's exactly how I'm still using it.

Nable80 avatar Apr 21 '25 21:04 Nable80

Have you committed your changes to the github?

Zombie-Ryushu avatar Apr 21 '25 21:04 Zombie-Ryushu

Well… nope. I just posted them above and that's it for now. Sorry.

Nable80 avatar Apr 21 '25 22:04 Nable80

I think EionRobb wants you to generate a Pull Request.

Zombie-Ryushu avatar Apr 22 '25 02:04 Zombie-Ryushu

Why are you putting so much effort in this? Skype is going to be shut down in a couple of weeks and this plugin becomes meaningless. I believe it's better to focus your attention and energy on purple-teams.

boris-petrov avatar Apr 22 '25 06:04 boris-petrov

I don't entirely disagree with you, but currently. I have an issue with the Teams Module throwing invalid Tennant ID errors when used with Spectrum 2. My actual goal is to resolve that problem and I suspect there may be a clue with the authentication process.

Zombie-Ryushu avatar Apr 22 '25 06:04 Zombie-Ryushu