ocilo / skype-http

Unofficial Skype API for Node.js via HTTP
https://ocilo.github.io/skype-http
MIT License
51 stars 24 forks source link

getContacts fails when the login is an email address #58

Closed demurgos closed 6 years ago

demurgos commented 6 years ago

When the credentials use an email address ({username: "example@yandex.ru", password: "bar"}), the getContacts api fails.

It sends a request to https://contacts.skype.com/contacts/v1/users/example@yandex.ru/contacts and receives a 401 - Unauthorized response with the body:

{"message":"Skype token validation failed!","stackTrace":null}

In this case, it should have sent the request to https://contacts.skype.com/contacts/v1/users/live:example/contacts.

It means that there should be some translation between the email address and corresponding Skype username to fix this issue.

James91 commented 6 years ago

Get Contacts fails when using my normal username. What do I need to do to resolve this?

demurgos commented 6 years ago

Is it a vague "Unable to fetch contacts" or do you have more details?

A good starting point to investigate it would be to add logs here: https://github.com/ocilo/skype-http/blob/1e56b0e9a7b9fbbedae199aee1c1503251d8d628/src/lib/api/get-contacts.ts#L23

You can log the request and response and compare it to the ones used by the official skype web app.

I noticed an update of the official application yesterday so this breakage may be related.

Either your problem is caused by an API change on the Skype side or the lack of "login to username" translation described in this issue.

demurgos commented 6 years ago

@James91 I am not able to reproduce the issue using skype-http but it may be related to a change in the contact URI. When checking with the web app, they use the following email for my account:

https://contacts.skype.com/contacts/v2/users/demurgos.net?page_size=100&reason=default
James91 commented 6 years ago

@demurgos I got the contacts coming back by modifying the contact-uri and getting it to display the above URL. However, I keep getting the following error, Has the JSON changed from before?

unknown-contact-type-name: Unknown contact type name undefined

    "contacts":[  
      {  
         "person_id":"",
         "mri":"",
         "display_name":"",
         "display_name_source":"profile",
         "profile":{  
            "name":{  
               "first":"",
               "surname":""
            }
         },
         "authorized":true,
         "auth_certificate":"",
         "blocked":false,
         "favorite":true,
         "creation_time":"2017-11-13T10:29:10.9715764Z",
         "relationship_history":{  }
James91 commented 6 years ago

With regards to the contacts - what do I have to change to get it to bring back the right section.

I believe that this must of changed in the api.

"profile":{ "name":{ "first":"", "surname":"" } },

But not too sure

demurgos commented 6 years ago

I will take a look at it this evening, thanks for the details.

demurgos commented 6 years ago

I was able to reproduce the issue with the new URL. Still looking into the error but you are right: it's caused by a change in the data schema.

James91 commented 6 years ago

Any update on this issue?

demurgos commented 6 years ago

I am planning to migrate to the new contact API during the week-end. I hope that this will solve your issue.

demurgos commented 6 years ago

I updated the lib to use the new contact API. I just want to do some tests and will send a PR today.