Terrance / SkPy

An unofficial Python library for interacting with the Skype HTTP API.
https://skpy.t.allofti.me
BSD 3-Clause "New" or "Revised" License
268 stars 66 forks source link

401 on SkypeImageMsg.fileContent #46

Closed dstelzer closed 6 years ago

dstelzer commented 7 years ago

When I try to get the fileContent of a SkypeImageMsg or SkypeFileMsg, I get this response

 [traceback details in my own app]
 File "/usr/local/lib/python3.5/dist-packages/skpy/msg.py", line 498, in fileContent
    auth=SkypeConnection.Auth.Authorize).content
  File "/usr/local/lib/python3.5/dist-packages/skpy/conn.py", line 215, in __call__
    raise SkypeApiException("{0} response from {1} {2}".format(resp.status_code, method, url), resp)
 skpy.core.SkypeApiException: ('401 response from GET https://api.asm.skype.com/v1/objects/0-eus-d2-9fc51dfcc7c37f83eac51aa51031ceb3/views/imgpsh_fullsize', <Response [401]>)

I'm not sure what to do about this. Is it the wrong authentication method?

Terrance commented 7 years ago

Can't seem to reproduce here. Please set SKPY_DEBUG_HTTP=1 in your environment, try retrieving the file again, and include the response from Skype below.

$ cat a.txt
A
>>> m
SkypeFileMsg(...)
>>> m.file
File(name='a.txt', size='2', ...)
>>> m.fileContent
<= [28/02 10:29:24] GET https://api.asm.skype.com/v1/objects/0-weu-d2-.../views/original
{}
=> [28/02 10:29:25] 200
A
b'A\n'
Terrance commented 7 years ago

@dstelzer: Any updates here?

Terrance commented 7 years ago

Tried it again but can't see any way to reproduce this... 😞

dstelzer commented 7 years ago

Here's what I saw with HTTP debugging.

[snip]
{'clientmessageid': '8611425457298071227',
               'composetime': '2017-03-30T22:21:53.953Z',
               'content': '<URIObject type="Picture.1" '
                          'uri="https://api.asm.skype.com/v1/objects/0-cus-d4-f4633e3c29a1bbd194f4a3a46d800dd4" '
                          'url_thumbnail="https://api.asm.skype.com/v1/objects/0-cus-d4-f4633e3c29a1bbd194f4a3a46d800dd4/views/imgt1" '
                          'ams_id="0-cus-d4-f4633e3c29a1bbd194f4a3a46d800dd4">You\'ve '
                          'received a new picture. View it at: <a '
                          'href="https://login.skype.com/login/sso?go=xmmfallback?pic=0-cus-d4-f4633e3c29a1bbd194f4a3a46d800dd4">https://login.skype.com/login/sso?go=xmmfallback?pic=0-cus-d4-f4633e3c29a1bbd194f4a3a46d800dd4</a><FileSize '
                          'v="146231" /><OriginalName v="" /><meta '
                          'type="photo" originalName="" /></URIObject>',
               'conversationLink': 'https://bn2-client-s.gateway.messenger.live.com/v1/users/ME/conversations/19:7ee9adcf32bb4e54af644413d4b08b80@thread.skype',
               'from': 'https://bn2-client-s.gateway.messenger.live.com/v1/users/ME/contacts/8:live:[username_redacted]',
               'id': '1490912513963',
               'messagetype': 'RichText/UriObject',
               'originalarrivaltime': '2017-03-30T22:21:53.953Z',
               'type': 'Message',
               'version': '1490912513963'}]}

<= [06/04 20:39:00] GET https://api.asm.skype.com/v1/objects/0-cus-d4-f4633e3c29a1bbd194f4a3a46d800dd4/views/imgpsh_fullsize
{}
=> [06/04 20:39:01] 401

Strangely enough, waiting a couple minutes and trying again can sometimes avoid this problem.

(Also, successfully downloading an image with HTTP debugging on often does strange things to my terminal. But I don't know if there's a way to avoid that.)

Terrance commented 7 years ago

Presumably the fallback link in there works for you? (I get an expired error but that's probably just masking the account mismatch -- if you get one now, try a fresh file upload first and test the corresponding link.) If that fails too, it's probably Skype serving you a dud file for some reason.

If you're signed in to Skype for Web, the direct file link should also just work in your browser (it only appears to require cookies for auth).

<= [06/04 20:39:00] GET https://api.asm.skype.com/v1/objects/0-cus-d4-f4633e3c29a1bbd194f4a3a46d800dd4/views/imgpsh_fullsize
{}
=> [06/04 20:39:01] 401

Have you missed a line under that? Presumably you didn't get the file, but did you get any form of response? Usually Skype APIs give a JSON error response...

Curiously, following your link, I get redirected to nus1-api.asm.skype.com and the same path, and then get a 403, as opposed to a file of mine that has no such redirect.

(Also, successfully downloading an image with HTTP debugging on often does strange things to my terminal. But I don't know if there's a way to avoid that.)

Indeed, that would be it trying to print binary files to your terminal. If you just send text files around whilst testing, you should be ok.

wilder11 commented 7 years ago

Edited -- please use sensible GitHub comment markup.

hi, I have also same problem. however this happens on Centos 7 Ubuntu seems to work ok.

Traceback (most recent call last):
  File "./andy.py", line 36, in <module>
    sk.loop()
  File "/usr/lib64/python2.7/site-packages/skpy/main.py", line 218, in loop
    self.cycle()
  File "/usr/lib64/python2.7/site-packages/skpy/main.py", line 207, in cycle
    self.onEvent(event)
  File "./andy.py", line 21, in onEvent
    print event.msg.fileContent
  File "/usr/lib64/python2.7/site-packages/skpy/util.py", line 227, in wrapper
    cache[key] = fn(*args, **kwargs)
  File "/usr/lib64/python2.7/site-packages/skpy/msg.py", line 593, in fileContent
    auth=SkypeConnection.Auth.Authorize).content
  File "/usr/lib64/python2.7/site-packages/skpy/conn.py", line 217, in __call__
    raise SkypeApiException("{0} response from {1} {2}".format(resp.status_code, method, url), resp)
skpy.core.SkypeApiException: ('401 response from GET https://api.asm.skype.com/v1/objects/0-cus-d2-1f8840328850101b4d1631f4552d5653/views/imgpsh_fullsize', <Response [401]>)
Terrance commented 7 years ago

There's no differences with SkPy between the two OSes, nor should Skype be able to detect any due to the consistent user agent. Please follow the previous requests to reproduce the issue with debugging, and to confirm if the fallback link still works.

Ashymad commented 7 years ago

I'm having the exact same problem. With SKPY_DEBUG_HTTP set to 1:

  1. Getting the message (its a text file with "test" inside):
    
    >>> m = sk.chats['8:username'].getMsgs()
    <= [15/10 21:29:59] GET https://db5-client-s.gateway.messenger.live.com/v1/users/ME/conversations/8:username/messages?syncState=250c000000383a732e6d696b756c69637a01831072875e010000a43ef1215f01000000&startTime=0&view=msnp24Equivalent
    {'params': {}}
    => [15/10 21:29:59] 200
    {'Cache-Control': 'no-store, must-revalidate, no-cache',
    'Content-Encoding': 'gzip',
    'Content-Length': '634',
    'Content-Type': 'application/json; charset=utf-8',
    'ContextId': 'tcid=8250543446289258611,server=DB5SCH101101028',
    'Date': 'Sun, 15 Oct 2017 21:29:58 GMT',
    'Pragma': 'no-cache',
    'X-Content-Type-Options': 'nosniff'}
    {'_metadata': {'lastCompleteSegmentEndTime': 1508102999127,
               'lastCompleteSegmentStartTime': 1505510953091,
               'syncState': 'https://db5-client-s.gateway.messenger.live.com/v1/users/ME/conversations/8:username/messages?syncState=250c000000383a732e6d696b756c69637a01831072875e010000578cf1215f01000000&startTime=0&view=msnp24Equivalent'},
    'messages': [{'clientmessageid': '1508102989845',
               'composetime': '2017-10-15T21:29:52.373Z',
               'content': '<URIObject type="File.1" '
                          'uri="https://api.asm.skype.com/v1/objects/0-weu-d3-4bd84805043a69cec674293762cced9d" '
                          'url_thumbnail="https://api.asm.skype.com/v1/objects/0-weu-d3-4bd84805043a69cec674293762cced9d/views/thumbnail"><Title>Title: '
                          'test.txt</Title><Description> Description: '
                          'test.txt</Description><a '
                          'href="https://login.skype.com/login/sso?go=webclient.xmm&amp;docid=0-weu-d3-4bd84805043a69cec674293762cced9d"> '
                          'https://login.skype.com/login/sso?go=webclient.xmm&amp;docid=0-weu-d3-4bd84805043a69cec674293762cced9d</a><OriginalName '
                          'v="test.txt"/><FileSize v="5"/></URIObject>',
               'conversationLink': 'https://db5-client-s.gateway.messenger.live.com/v1/users/ME/conversations/8:username',
               'conversationid': '8:username',
               'from': 'https://db5-client-s.gateway.messenger.live.com/v1/users/ME/contacts/8:username',
               'id': '1508102992377',
               'messagetype': 'RichText/Media_GenericFile',
               'originalarrivaltime': '2017-10-15T21:29:52.373Z',
               'type': 'Message',
               'version': '1508102992377'}]}
2.  Downloading the file:

m[0].fileContent <= [15/10 21:42:01] GET https://api.asm.skype.com/v1/objects/0-weu-d3-4bd84805043a69cec674293762cced9d/views/original {} => [15/10 21:42:02] 401 {'Content-Length': '0', 'Date': 'Sun, 15 Oct 2017 21:42:01 GMT', 'Server': 'Microsoft-IIS/8.5', 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains', 'X-Content-Type-Options': 'nosniff', 'X-Powered-By': 'ARR/2.5, ASP.NET'}

Traceback (most recent call last): File "", line 1, in File "/home/shyman/.pyenv/versions/skycord/lib/python3.6/site-packages/skpy/util.py", line 227, in wrapper cache[key] = fn(*args, **kwargs) File "/home/shyman/.pyenv/versions/skycord/lib/python3.6/site-packages/skpy/msg.py", line 568, in fileContent auth=SkypeConnection.Auth.Authorize).content File "/home/shyman/.pyenv/versions/skycord/lib/python3.6/site-packages/skpy/conn.py", line 217, in call raise SkypeApiException("{0} response from {1} {2}".format(resp.status_code, method, url), resp) skpy.core.SkypeApiException: ('401 response from GET https://api.asm.skype.com/v1/objects/0-weu-d3-4bd84805043a69cec674293762cced9d/views/original', <Response [401]>)


If I open the api.asm.skype.com link in a browser I can download the file no problem. Opening the fallback link in browser shows me "This is your message" and a play button, pressing it does nothing.
Terrance commented 7 years ago

Let's reopen this as it's clearly affecting multiple users, despite not being reproducible over here. 🙁

Terrance commented 7 years ago

Opening the fallback link in browser shows me "This is your message" and a play button

Assuming that's still test.txt, I have no idea why a play button appears...

@Ashymad, @wilder11: Can you try sending a file through Skype for Web, and then capturing and downloading it from SkPy? You can run a SkypeEventLoop and react to a SkypeNewMessageEvent where the event's msg property is a SkypeFileMsg, then try retrieving the content like before.

Ashymad commented 7 years ago

Here is the code I used:

from skpy import *

class MySkype(SkypeEventLoop):
    def onEvent(self, event):
        if event.type == "NewMessage":
            if event.msg.type == "RichText/Media_GenericFile":
                file = event.msg.fileContent

username = "BotAccount"
password = ""

Skype(username,password,".tokens-test")

MySkypeLoop = MySkype(tokenFile=".tokens-test", autoAck=True)
MySkypeLoop.loop()

Then:

export SKPY_DEBUG_HTTP=1
python ./test.py > test.log 2>&1

Then I've sent a text file from my account (through Skype for Web) to the bot. Here is test.log Maybe the problem is that I am running the script on a remote server?

Terrance commented 7 years ago

Ok, so it looks like it's at least parsing the message correctly, but we're sending the wrong kind of credentials. It's possible something has changed within Skype for Web, in which case it may be using different authentication now.

If you've still got that message hanging around, can you try using https://web.skype.com to fetch the attachment? Open developer tools, try to download the file, find the request in the Network tab (on Chrome at least), and get a copy of the request headers and body.

Ashymad commented 7 years ago

Request headers:

GET /v1/objects/0-weu-d3-50424a9ccc973ea131da4209652afa83/views/original HTTP/1.1
Host: api.asm.skype.com
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:57.0) Gecko/20100101 Firefox/57.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Referer: https://web.skype.com/en/
Cookie: SC=CC=:CCY=:LC=en:LIM=:RS=d:TM=1508355247:TS=1506340084:TZ=:VAT=:VER=; SWADCC=TS=1506340091:TM=1506340091; SWACC=TS=1506626683:TM=1506626683; SSP=linux; MSFPC=ID=63ce316bcc101742b49adbda8785d49d&CS=1&LV=201709&V=1; skype-cookie-policy=1; MSCC=1506756172; s_pers=%20s_fid%3D5A081F7341145EFA-11333A4437F17D54%7C1570361758933%3B%20gpv_p23%3Dno%2520value%7C1507291558935%3B%20s_nr%3D1507289758936-Repeat%7C1570361758936%3B; skypetoken_asm=eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6IjEzIn0.eyJpYXQiOjE1MDgzNTUyNDUsImV4cCI6MTUwODQ0MTY0Mywic2t5cGVpZCI6ImxpdmU6bjk5ODUxMCIsInNjcCI6OTU4LCJjc2kiOiIxIiwiY2lkIjoiZTNhZDQ0OWExMzhiODViMyIsImFhdCI6MTUwODM1NTA5NX0.cuTcXXQkY2eNi-_SUOynXZGoTD5Rx0Gm_GXGYwpecx4uf5iUJPeLEdKJWMu5ae8wQZz8jVP2b7EZWEcoIhwYigrL54t27RBe6KA6HMyzvpxSKRqDl8aDcZGhhM2kp5mqR61xVf0xXJgqG5fLmsWUu-dN_39QBhG45Vkv1OxhRc_NEOedroMoHZvEsKUZ0aedVFFiWnYR0ITjFgqm; platformid_asm=908; skplet=1508441645
Connection: keep-alive
Upgrade-Insecure-Requests: 1
DNT: 1

Response headers:

HTTP/1.1 200 OK
Cache-Control: no-cache, max-age=0, s-maxage=0, private
Content-Range: bytes 0-4/5
Server: Microsoft-IIS/8.5
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Content-Type-Options: nosniff
Content-Disposition: attachment; filename=test.txt
X-Powered-By: ARR/2.5, ASP.NET
Date: Wed, 18 Oct 2017 19:34:24 GMT
Content-Length: 5

Response:

test

I've also tried

curl 'https://api.asm.skype.com/v1/objects/0-weu-d3-50424a9ccc973ea131da4209652afa83/views/original' -H 'Host: api.asm.skype.com' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:57.0) Gecko/20100101 Firefox/57.0' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'Referer: https://web.skype.com/en/' -H 'Cookie: SC=CC=:CCY=:LC=en:LIM=:RS=d:TM=1508355247:TS=1506340084:TZ=:VAT=:VER=; SWADCC=TS=1506340091:TM=1506340091; SWACC=TS=1506626683:TM=1506626683; SSP=linux; MSFPC=ID=63ce316bcc101742b49adbda8785d49d&CS=1&LV=201709&V=1; skype-cookie-policy=1; MSCC=1506756172; s_pers=%20s_fid%3D5A081F7341145EFA-11333A4437F17D54%7C1570361758933%3B%20gpv_p23%3Dno%2520value%7C1507291558935%3B%20s_nr%3D1507289758936-Repeat%7C1570361758936%3B; skypetoken_asm=eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6IjEzIn0.eyJpYXQiOjE1MDgzNTUyNDUsImV4cCI6MTUwODQ0MTY0Mywic2t5cGVpZCI6ImxpdmU6bjk5ODUxMCIsInNjcCI6OTU4LCJjc2kiOiIxIiwiY2lkIjoiZTNhZDQ0OWExMzhiODViMyIsImFhdCI6MTUwODM1NTA5NX0.cuTcXXQkY2eNi-_SUOynXZGoTD5Rx0Gm_GXGYwpecx4uf5iUJPeLEdKJWMu5ae8wQZz8jVP2b7EZWEcoIhwYigrL54t27RBe6KA6HMyzvpxSKRqDl8aDcZGhhM2kp5mqR61xVf0xXJgqG5fLmsWUu-dN_39QBhG45Vkv1OxhRc_NEOedroMoHZvEsKUZ0aedVFFiWnYR0ITjFgqm; platformid_asm=908; skplet=1508441645' -H 'Connection: keep-alive' -H 'Upgrade-Insecure-Requests: 1' -H 'DNT: 1'

with mixed success. At first I didn't get anything then an unknown SSL protocol error, finally it started working. After I did that, SkPy suddenly was able to download files and images as well... EDIT: The next day it's unable to download them again.

Terrance commented 7 years ago

Ugh. I wonder if there's another API call that needs to be made first, before the link in the message becomes valid (after which both Skype for Web and SkPy can use it because the account / session is "authorised").

Ashymad commented 7 years ago

Today SkPy is able to download again. For no reason at all.I was not at home even, but my bot on the server suddenly became able to download them.

ghost commented 7 years ago

I ran into the same problem. I have done a little troubleshooting and it appears there is a similar issue as with login.skype.com failing to redirect to api.asm.skype.com; in this case api.asm.skype.com fails to redirect to the proper "cloud server" resulting in the file not being found and returning a 401.

I did a silly little mod to the two functions (for file attachments and images) in msg.py in SkPy to get around this problem by first trying urlFull as returned from the API, and if that doesn't work I step through a ladder of exceptions for each API-server that I have identified so far, until I find the correct one for my file. If all fail I just leave it. Ugly I know, but it works for now. ;)

From what I have seen so far these are the servers api.asm.skype.com redirects to: nus1-api.asm.skype.com weu1-api.asm.skype.com neu1-api.asm.skype.com as-api.asm.skype.com sa1-api.asm.skype.com eus1-api.asm.skype.com ea1-api.asm.skype.com

Terrance commented 7 years ago

there is a similar issue as with login.skype.com failing to redirect to api.asm.skype.com; in this case api.asm.skype.com

Is that from opening the fallback link in the message in a browser, or from opening a file directly from Skype for Web, or both?

I step through a ladder of exceptions for each API-server that I have identified so far

There's bound to be another way to figure out where a file is. Not sure how they're allocated -- if you send multiple files, are they consistently on the same file server? IIRC I've personally only ever seen weu1 and neu1 from my testing.

SergeiMinaev commented 6 years ago

I'm having same issue. It happens sometimes and I absolutely have no idea why. It doesn't happen in web skype.

SkypeApiException('401 response from GET https://api.asm.skype.com/v1/objects/<...>/views/imgpsh_fullsize', <Response [401]>

The one hint I see is difference hosts in headers: sometimes is api.asm.skype.com and sometimes weu1-api.asm.skype.com.

Terrance commented 6 years ago

Unfortunately I'm no further forward here, still not seen it happen myself. As above, any further details would be great if you can find anything.

SergeiMinaev commented 6 years ago

I've noticed that problematic urls contains name of server. Like this: urlFull: https://api.asm.skype.com/v1/objects/0-weu-d3-759ce324c4d88734b603e03cbde1333d urlView: https://login.skype.com/login/sso?go=webclient.xmm&pic=0-weu-d3-759ce324c4d88734b603e03cbde1333d

It contains "-weu-". When I open first one in browser it returns 401 error. When I open second one it returns 200 and redirects to weu1-api.asm.skype.com. So if I replace api.asm.skype.com with weu1-api.asm.skype.com it loads fine.

Same in python shell:

>>> url = "https://{0}api.asm.skype.com/v1/objects/{1}/views/imgpsh_fullsize".format('', '0-weu-d3-759ce324c4d88734b603e03cbde1333d')
>>> sk.conn("GET", url, auth=sk.conn.Auth.Authorize)
Traceback (most recent call last):
  File "<input>", line 1, in <module>
    sk.conn("GET", url, auth=sk.conn.Auth.Authorize)
  File "/media/work/envs/mtbz/lib/python3.5/site-packages/skpy/conn.py", line 217, in __call__
    raise SkypeApiException("{0} response from {1} {2}".format(resp.status_code, method, url), resp)
skpy.core.SkypeApiException: ('401 response from GET https://api.asm.skype.com/v1/objects/0-weu-d3-759ce324c4d88734b603e03cbde1333d/views/imgpsh_fullsiz
e', <Response [401]>)
>>> 
>>> 
>>> url = "https://{0}api.asm.skype.com/v1/objects/{1}/views/imgpsh_fullsize".format('weu1-', '0-weu-d3-759ce324c4d88734b603e03cbde1333d')
>>> sk.conn("GET", url, auth=sk.conn.Auth.Authorize)
<Response [200]>
>>> 

According to @dforsell there is a lot of servers. Also seems like all image urls contains /0-something-d. We can do some dirty trick like this:

>>> import re
>>> url = 'https://api.asm.skype.com/v1/objects/0-weu-d3-759ce324c4d88734b603e03cbde1333d'
>>> img_id = re.search('v1/objects/(.+)', url).group(1)
>>> name = re.search('0-([A-Za-z0-9]+)-d', img_id).group(1)
>>> new_url = 'https://'+name+'1-api.asm.skype.com/v1/objects/'+img_id
>>> sk.conn("GET", new_url, auth=sk.conn.Auth.Authorize)
<Response [200]>
>>>

I know it looks ugly but seems like it works :) Need more testing ofc.

Ashymad commented 6 years ago

I'm testing your hack, @SergeiMinaev , and it seems to work.

Terrance commented 6 years ago

Interesting, I wonder which clients are generating the dud links then. I suppose Skype for Web rewrites them somewhere, similar to the workaround above.

I'm going to be off the grid for the rest of this week, but I'll take a proper look after that. Hopefully, if it proves successful, I'll get such a workaround in place. 🙂

Terrance commented 6 years ago

Based on @SergeiMinaev's sample above, I've pushed a potential fix to the file-url-fix branch.

For those who have seen issues reading file content from messages, please try this branch and report back on whether it works for you or not.

I'm not particularly happy on using {server-id}1-asm.skype.com as the hostname (with server-id extracted from the object URL) as this feels rather brittle, so I'm keen to hear if there are any server names that don't satisfy this pattern (@dforsell mentioned as-api.asm.skype.com so I'm unsure if/when that will come up). So far I've only come across weu1 and neu1 during my testing.

Ashymad commented 6 years ago

I've been testing the fix for the last week or so and everything is working quite nicely.

Terrance commented 6 years ago

I've merged it as-is for lack of a better solution. Hopefully this puts us in a better position than without.

goaucomp commented 1 year ago

I still see this error in 0.10.6

An error occurred: 401 Client Error: Unauthorized for url: https://api.asm.skype.com/v1/objects/0-sa-d1-86d6de52532838282bd170491a147ffc/views/original

goaucomp commented 1 year ago

Can you please help if there is a workaround to get rid of this error 401 ?

Terrance commented 1 year ago

If you try to download the same file in Skype for Web, what does the URL look like?

goaucomp commented 1 year ago

This is as seen from the browser

Request URL: https://gateway.bingviz.microsoftapp.net/receive?app=skype Request Method: POST Status Code: 200 OK

goaucomp commented 1 year ago

Prior to the above request there was a

Request URL: https://gateway.bingviz.microsoftapp.net/receive?app=skype Request Method: OPTIONS Status Code: 204 No Content

Terrance commented 1 year ago

gateway.bingviz.microsoftapp.net appears to be client analytics/tracking and is unrelated to downloading images. I'd expect the request you're looking for to look like the one SkPy is trying to make but on a different domain.

goaucomp commented 1 year ago

I tried another instance of download from the code and the browser(skype web). The URL that is being used seems to be the same in both the case.

code:

An error occurred: 401 Client Error: Unauthorized for url: https://api.asm.skype.com/v1/objects/0-sa-d6-d1754454c51db5164aa91d2078ae8983/views/original

skype web:

Refer attachment.

Pasted below 'Copy -> Copy all as cURL (cmd)' of the highlighted network packet in the attachment:

(removed)

Terrance commented 1 year ago

I've removed your paste as you leaked all of your tokens -- I'd suggest signing out of Skype for Web and resetting your password ASAP, and avoid pasting raw tokens in public places like GitHub in future.

The relevant request:

curl "https://api.asm.skype.com/v1/objects/0-sa-d6-.../views/original"
  ...
  -H "cookie: ..., skypetoken_asm=eyJhb..."
  ...

Looks like they may have switched to cookie authorisation instead of headers. The existing header authorisation continues to work for me, but I've experimentally pushed branch asm-cookie which does the cookie authorisation instead (which also works for me so I'm hoping is valid for existing files).

Can you check if that branch works for you?

goaucomp commented 1 year ago

$ pip install git+https://github.com/Terrance/SkPy.git@asm-cookie DEPRECATION: Loading egg at c:\users\91821\appdata\local\programs\python\python311\lib\site-packages\alright-2.5-py3.11.egg is deprecated. pip 23.3 will enforce this behaviour change. A possible replacement is to use pip for package installation.. DEPRECATION: Loading egg at c:\users\91821\appdata\local\programs\python\python311\lib\site-packages\platformdirs-3.10.0-py3.11.egg is deprecated. pip 23.3 will enforce this behaviour change. A possible replacement is to use pip for package installation.. Collecting git+https://github.com/Terrance/SkPy.git@asm-cookie Cloning https://github.com/Terrance/SkPy.git (to revision asm-cookie) to c:\cygwin64\tmp\pip-req-build-l2n06uo2 Running command git clone --filter=blob:none --quiet https://github.com/Terrance/SkPy.git 'C:\cygwin64\tmp\pip-req-build-l2n06uo2' Running command git checkout -b asm-cookie --track origin/asm-cookie Branch 'asm-cookie' set up to track remote branch 'asm-cookie' from 'origin'. Switched to a new branch 'asm-cookie' Resolved https://github.com/Terrance/SkPy.git to commit 22443921bd1365d8032aba07c8a4c47a25b2708d Preparing metadata (setup.py) ... done Requirement already satisfied: beautifulsoup4 in c:\users\91821\appdata\local\programs\python\python311\lib\site-packages (from SkPy==0.0.0) (4.12.2) Requirement already satisfied: requests in c:\users\91821\appdata\local\programs\python\python311\lib\site-packages (from SkPy==0.0.0) (2.31.0) Requirement already satisfied: soupsieve>1.2 in c:\users\91821\appdata\local\programs\python\python311\lib\site-packages (from beautifulsoup4->SkPy==0.0.0) (2.4.1) Requirement already satisfied: charset-normalizer<4,>=2 in c:\users\91821\appdata\local\programs\python\python311\lib\site-packages (from requests->SkPy==0.0.0) (3.2.0) Requirement already satisfied: idna<4,>=2.5 in c:\users\91821\appdata\local\programs\python\python311\lib\site-packages (from requests->SkPy==0.0.0) (3.4) Requirement already satisfied: urllib3<3,>=1.21.1 in c:\users\91821\appdata\local\programs\python\python311\lib\site-packages (from requests->SkPy==0.0.0) (1.26.16) Requirement already satisfied: certifi>=2017.4.17 in c:\users\91821\appdata\local\programs\python\python311\lib\site-packages (from requests->SkPy==0.0.0) (2023.7.22)

I did run pip install command as above and re ran my listener, but no change in behavior. Am I missing anything here ?

Terrance commented 1 year ago

I can't tell from that output, as it doesn't shows SkPy itself actually being updated -- I'd expect after the various "Requirement already satisfied" messages something like...

Installing collected packages: SkPy
  Attempting uninstall: SkPy
    Found existing installation: SkPy 0.10.6
    Uninstalling SkPy-0.10.6:
      Successfully uninstalled SkPy-0.10.6
  Running setup.py develop for SkPy
Successfully installed SkPy-0.0.0

I also haven't seen the request made to download your file again this time -- as with the previous reports above, set SKPY_DEBUG_HTTP=1 in your environment to actually log the request/response, and if you're running the updated branch then you should see the request as...

<= [11/10 23:52:52] GET https://xyz1-api.asm.skype.com/v1/objects/0-xyz-000-0000000000000000646c76a75b0e4cc1/views/original
{'cookies': {'skypetoken_asm': '***'}, 'headers': {}}
=> [11/10 23:52:52] 200