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
263 stars 66 forks source link

('Account action required (https://account.live.com/identity/confirm) - what's the proper statement that fix this issue? #224

Closed Drill-N-Bass closed 1 year ago

Drill-N-Bass commented 1 year ago

My issue was discussed earlier on Github, but I don't understand how to use documentation in my case.

I have a Django project that worked well in development with:

sk = Skype("+48666777888999", "MyPassForSkype")
ch = sk.contacts["live:.cid.fooBar12345673"].chat

msg = ch.sendMsg(
                skype_comment,
                rich=True
                ) 

msg

But, in production on Nginx I have ('Account action required (https://account.live.com/identity/confirm), login with a web browser first', <Response [200]>)

I've tried to set statements as far as I understand documentation in my views.py class that should trigger sending a message:

sk = Skype("+48666777888999", "MyPassForSkype")

sk.conn.soapLogin("+48666777888999", "MyPassForSkype") # I also tried sk.conn.liveLogin("+48666777888999", "MyPassForSkype")
sk.conn

ch = sk.contacts["live:.cid.fooBar12345673"].chat
msg = ch.sendMsg(
                skype_comment,
                rich=True
                ) 

msg

...but it doesn't work.

I'm able to log in via https://account.live.com with my phone number and pass (a Live (Microsoft) account.). Same on the Skype win GUI. Also the same via https://web.skype.com/.

The goal: is to have a comment form where all messages from the web page are displayed on a page and, at the same time, send to one account on Skype.

I don't quite understand how tokens work in Skpy - If there is some documentation that can give me a deeper understanding I would be happy to see it. The code I present here is all I used.

I would be very grateful for your help/guidance in solving this problem.

Terrance commented 1 year ago

I'm able to log in via https://account.live.com/

Have you tried logging in from the same IP address as where your program's running? See Authentication → Error messages.

Ultimately SkPy has no control over whether Microsoft's login pages will flag a given authentication for manual steps or not.

Drill-N-Bass commented 1 year ago

Have you tried logging in from the same IP.

No, the address is different - I'm sorry that I didn't mention that clearly enough.

I'm able to use Skpy on my computer - with Tkinter and with Django too (development). But the problem happened when I deploy my Django project on AWS Elastic Beanstalk (production). So the IP comes from AWS servers. My site is handled by an external server via Elastic Beanstalk.

But, it is kind of strange because locally I never needed to log in via https://account.live.com/. I could just run my GUI with Skpy and it was and is working ( just checked). No need to even use Skype before Skpy.

One more thing: I'm sending just singular messages via skpy only, so it's not a problem related to the volume of messages.

It's my first deployment ( still in progress) so I don't know much about the bigger picture related to my problem. I'm still figuring out how can I get logs in my shell (locally) from that AWS server.

So, is it possible to somehow fix it? Or, at least, can you tell me what can I check/do to solve this puzzle?

Terrance commented 1 year ago

It's quite likely that Microsoft will treat automated logins from known hosting infrastructure like AWS with some hostility. Remember that SkPy is an unofficial wrapper around the APIs of a web app, one which does not expect (and will defend against) being automated.

As above, using a browser from your server's IP address (by proxy or otherwise) may help to clear interstitual pages during login.

Drill-N-Bass commented 1 year ago

I (kind of) solved the problem! :)

Before I get to my solution, I want to write some details about the whole idea of using Skpy with my page.

  1. I have a skype account on my pc.
  2. I have built a page with Django, where I have a comment form.
  3. I wanted to create a mechanism that will send me comments from users (from that comment form) to my skype account, so I can see new comments as messages on skype.

To this point where I was using just Django and its developer's Apache server, things worked well.

Today I realized that the problem started to appear also in my local server. I don't know for sure why, but I assume that It has something to do with the fact that I'm using now static files and other features from AWS (S3 and ElasticBeanstalk) locally. In other words, despite the fact that I have a Django project that I'm running locally with an Apache server, some settings and mechanisms link this site's actions with content from AWS. I'm still learning AWS and related topics.

I assume that the problem may be (but I'm not sure) related to the fact that I'm in Poland with polish IP and AWS ElasticBeanstalk, S3 is located in Paris i.e. "eu-west-3". Maybe because of that, Microsoft detects that I use my account in a different country than I used to use.

Now, having AWS as a part of my backend, I've set in settings.py:

"""
AWS specific settings for S3 with Boto3 library s15e219 10:00
"""
AWS_STORAGE_BUCKET_NAME = "django-foo-python-bucket"
AWS_S3_REGION_NAME = "eu-west-3"
AWS_ACCESS_KEY_ID = "MYIDFOO123"
AWS_SECRET_ACCESS_KEY = "MYSECRETKEYFOO123"

AWS_S3_CUSTOM_DOMAIN = f"{AWS_STORAGE_BUCKET_NAME}.s3.amazonaws.com"

"""
Because besides Admin, users can upload files, I need to split folders for each for security risks.
Because of that I removed `STATICFILES_STORAGE =  "storages.backends.s3boto3.S3Boto3Storage"`
and create several paths for files. Different for admin, different for users. 
"""

STATICFILES_FOLDER = "static"
MEDIAFILES_FOLDER = "media"

STATICFILES_STORAGE =  "custom_storages.StaticFileStorage" 
DEFAULT_FILE_STORAGE = "custom_storages.MediaFileStorage"

Inspired by this doc, instead of using Live ("Account action required (https://…), login with a web browser first"), I'm using now SOAP.

Step by step on how to solve the problem:

  1. Entry point was to log in via phone number. I had a skype account with my phone number.
  2. I've created a new Skype account based on my Gmail (yes, Gmail can be used). In other words, as a login name, I posted my Gmail address.
  3. Now in my code I wrote:
    
    sk = Skype("MYGMAILADRESS@gmail.com", "MyPassForSkype")
    ch = sk.contacts["live:.cid.fooBar12345673"].chat

msg = ch.sendMsg( skype_comment, rich=True )

msg



Sadly I need a new account, but at least it works. 
**If someone has any idea how to set it up with a phone number instead of an email, please let me know!**