Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot client.authenticate #15

Open
enclude opened this issue Mar 22, 2022 · 0 comments
Open

Cannot client.authenticate #15

enclude opened this issue Mar 22, 2022 · 0 comments

Comments

@enclude
Copy link

enclude commented Mar 22, 2022

Hello,
when I use code from readme.md i has clear output.

When try pt "client.authenticate()" on main() function, got error like this:
tractive.py:24: RuntimeWarning: coroutine 'Tractive.authenticate' was never awaited client.authenticate() RuntimeWarning: Enable tracemalloc to get the object allocation traceback

When add "await" before "client.authenticate()"

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/aiotractive/api.py", line 106, in authenticate
    response.raise_for_status()
  File "/usr/local/lib/python3.8/dist-packages/aiohttp/client_reqrep.py", line 1004, in raise_for_status
    raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 400, message='Bad Request', url=URL('https://graph.tractive.com/3/auth/token')

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "tractive.py", line 31, in <module>
    asyncio.run(main())
  File "/usr/lib/python3.8/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "tractive.py", line 24, in main
    await client.authenticate()
  File "/usr/local/lib/python3.8/dist-packages/aiotractive/tractive.py", line 15, in authenticate
    return await self._api.authenticate()
  File "/usr/local/lib/python3.8/dist-packages/aiotractive/api.py", line 117, in authenticate
    raise TractiveError from error
aiotractive.exceptions.TractiveError

My Python code:

     1  import requests        # For CURL request
     2  import argparse        # Args for Python scripts
     3  import asyncio        # Use for async function
     4  from aiotractive import Tractive   # Use for Tractive connection
     5
     6  # Initiate the parser
     7  parser = argparse.ArgumentParser()
     8
     9  parser.add_argument("-email", help="Google e-mail", action="store")
    10  parser.add_argument("-password", help="Google e-mail", action="store")
    11  parser.add_argument("-traccar_server", help="traccar server", action="store")
    12  parser.add_argument("-tractive_id", help="traccar server", action="store")
    13
    14  args = parser.parse_args()
    15
    16  EMAIL = args.email
    17  PASSWORD = args.password
    18  TRACCAR_SERVER = args.traccar_server
    19  TRACTIVE_ID = args.tractive_id
    20
    21  async def main():
    22    async with Tractive(EMAIL, PASSWORD) as client:
    23      # interact with the client here
    24      client.authenticate()
    25      pass
    26
    27
    28
    29  if __name__ == "__main__":
    30    asyncio.run(main())
    31

Someone can share with me property use of this library for Tractive? I need get only GPS from my GPS for dog.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant