nwunderly / starlette-discord

"Login with Discord" support for Starlette and FastAPI
https://starlette-discord.rtfd.io
MIT License
32 stars 11 forks source link

[Bug Report] TypeError: argument of type 'int' is not iterable #13

Closed xFGhoul closed 2 years ago

xFGhoul commented 3 years ago

Code:

Traceback (most recent call last):
  File "C:\Users\Dante\AppData\Local\pypoetry\Cache\virtualenvs\mai-backend-h2M1C5Y5-py3.10\lib\site-packages\uvicorn\protocols\http\httptools_impl.py", line 375, in run_asgi
    result = await app(self.scope, self.receive, self.send)
  File "C:\Users\Dante\AppData\Local\pypoetry\Cache\virtualenvs\mai-backend-h2M1C5Y5-py3.10\lib\site-packages\uvicorn\middleware\proxy_headers.py", line 75, in __call__
    return await self.app(scope, receive, send)
  File "C:\Users\Dante\AppData\Local\pypoetry\Cache\virtualenvs\mai-backend-h2M1C5Y5-py3.10\lib\site-packages\uvicorn\middleware\debug.py", line 96, in __call__
    raise exc from None
  File "C:\Users\Dante\AppData\Local\pypoetry\Cache\virtualenvs\mai-backend-h2M1C5Y5-py3.10\lib\site-packages\uvicorn\middleware\debug.py", line 93, in __call__
    await self.app(scope, receive, inner_send)
  File "C:\Users\Dante\AppData\Local\pypoetry\Cache\virtualenvs\mai-backend-h2M1C5Y5-py3.10\lib\site-packages\fastapi\applications.py", line 208, in __call__
    await super().__call__(scope, receive, send)
  File "C:\Users\Dante\AppData\Local\pypoetry\Cache\virtualenvs\mai-backend-h2M1C5Y5-py3.10\lib\site-packages\starlette\applications.py", line 112, in __call__
    await self.middleware_stack(scope, receive, send)
  File "C:\Users\Dante\AppData\Local\pypoetry\Cache\virtualenvs\mai-backend-h2M1C5Y5-py3.10\lib\site-packages\starlette\middleware\errors.py", line 181, in __call__
    raise exc
  File "C:\Users\Dante\AppData\Local\pypoetry\Cache\virtualenvs\mai-backend-h2M1C5Y5-py3.10\lib\site-packages\starlette\middleware\errors.py", line 159, in __call__
    await self.app(scope, receive, _send)
  File "C:\Users\Dante\AppData\Local\pypoetry\Cache\virtualenvs\mai-backend-h2M1C5Y5-py3.10\lib\site-packages\starlette\exceptions.py", line 82, in __call__
    raise exc
  File "C:\Users\Dante\AppData\Local\pypoetry\Cache\virtualenvs\mai-backend-h2M1C5Y5-py3.10\lib\site-packages\starlette\exceptions.py", line 71, in __call__
    await self.app(scope, receive, sender)
  File "C:\Users\Dante\AppData\Local\pypoetry\Cache\virtualenvs\mai-backend-h2M1C5Y5-py3.10\lib\site-packages\starlette\routing.py", line 656, in __call__
    await route.handle(scope, receive, send)
  File "C:\Users\Dante\AppData\Local\pypoetry\Cache\virtualenvs\mai-backend-h2M1C5Y5-py3.10\lib\site-packages\starlette\routing.py", line 259, in handle
    await self.app(scope, receive, send)
  File "C:\Users\Dante\AppData\Local\pypoetry\Cache\virtualenvs\mai-backend-h2M1C5Y5-py3.10\lib\site-packages\starlette\routing.py", line 61, in app
    response = await func(request)
  File "C:\Users\Dante\AppData\Local\pypoetry\Cache\virtualenvs\mai-backend-h2M1C5Y5-py3.10\lib\site-packages\fastapi\routing.py", line 226, in app
    raw_response = await run_endpoint_function(
  File "C:\Users\Dante\AppData\Local\pypoetry\Cache\virtualenvs\mai-backend-h2M1C5Y5-py3.10\lib\site-packages\fastapi\routing.py", line 159, in run_endpoint_function
    return await dependant.call(**values)
  File "C:\Users\Dante\Documents\Mai\website\backend\main.py", line 104, in redirect
    user = await discord.login(code)
  File "C:\Users\Dante\AppData\Local\pypoetry\Cache\virtualenvs\mai-backend-h2M1C5Y5-py3.10\lib\site-packages\starlette_discord\client.py", line 292, in login
    user = await session.identify()
  File "C:\Users\Dante\AppData\Local\pypoetry\Cache\virtualenvs\mai-backend-h2M1C5Y5-py3.10\lib\site-packages\starlette_discord\client.py", line 126, in identify
    data_user = await self._discord_request('/users/@me')
  File "C:\Users\Dante\AppData\Local\pypoetry\Cache\virtualenvs\mai-backend-h2M1C5Y5-py3.10\lib\site-packages\starlette_discord\client.py", line 103, in _discord_request
    self._discord_token = await self.fetch_token(
  File "C:\Users\Dante\AppData\Local\pypoetry\Cache\virtualenvs\mai-backend-h2M1C5Y5-py3.10\lib\site-packages\starlette_discord\oauth.py", line 318, in fetch_token
    auth = aiohttp.BasicAuth(login=client_id, password=client_secret)
  File "C:\Users\Dante\AppData\Local\pypoetry\Cache\virtualenvs\mai-backend-h2M1C5Y5-py3.10\lib\site-packages\aiohttp\helpers.py", line 142, in __new__
    if ":" in login:
TypeError: argument of type 'int' is not iterable
nwunderly commented 3 years ago

I can't say for sure since I can't see the code, but looks like you set client_id to an int? It should be a string.

I can add str() so ints work too eventually, but in the meantime if you make sure you're only passing strings into the DiscordOAuthClient's initialization it should fix the bug.

Checked docs too, the params aren't documented as strings, so that's also something I'll be fixing at some point. I'll leave this issue open until these are fixed.

nwunderly commented 2 years ago

Solved with release 0.2.0.