OpenXbox / xbox-webapi-python

A python library to authenticate with Xbox Live via your Microsoft Account and provides Xbox related Web-API.
https://pypi.python.org/pypi/xbox-webapi
MIT License
175 stars 44 forks source link

Had helped someone new at programming with this correction #69

Closed mjlomeli closed 2 years ago

mjlomeli commented 2 years ago

Hi, someone who was really into your application asked me to debug this for him. I wanted to redirect this to you for people who weren't tech-savvy but really wanted to use your application. Just in case.

Your github documentation cover:

import sys
import asyncio
from aiohttp import ClientSession // also needs to import ClientResponseError
from xbox.webapi.api.client import XboxLiveClient
from xbox.webapi.authentication.manager import AuthenticationManager
from xbox.webapi.authentication.models import OAuth2TokenResponse
from xbox.webapi.common.exceptions import AuthenticationException
from xbox import *
client_id = 'YOUR CLIENT ID HERE'
client_secret = 'YOUR CLIENT SECRET HERE'

 ... 

        try:
            await auth_mgr.refresh_tokens()
        except ClientResponseError:
            print("Could not refresh tokens")
            sys.exit(-1)

...

def main()
      asyncio.run(async_main())

Lastly, we tried to run your main file but it fails the run method:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "<input>", line 78, in main
  File "C:\Users\...\asyncio\runners.py", line 44, in run 
return loop.run_until_complete(main)
  File "C:\Users\...\base_events.py", line 642, in run_until_complete 
return future.result()
  File "<input>", line 28, in async_main
TypeError: __init__() takes 1 positional argument but 5 were given

I see your AuthenticationManager doesn't have an init accepting arguments but your documentation says it does.

Github main example

async def async_main():

    tokens_file = "./token.json" # replace with path in auth scrip or just paste file with tokens here
    async with ClientSession() as session:
        auth_mgr = AuthenticationManager(
            session, client_id, client_secret, ""
        )

manager.py: AuthenticationManager(object) class

   def __init__(self):
        """
        Initialize an instance of :class:`AuthenticationManager`
        """
        self.session = requests.session()

        self.email_address = None
        ....

Any advice would be nice. Thank you.

ReenigneArcher commented 2 years ago

The readme should probably be updated. Use https://github.com/OpenXbox/xbox-webapi-python/blob/master/xbox/webapi/scripts/authenticate.py as an example.

mjlomeli commented 2 years ago

thank you. I'll take a look at it tomorrow.