Skip to content

Using user token while executing fetch_users throws an HTTP error #2578

@bsalha1

Description

@bsalha1

Summary

If you use a user token (as opposed to a bot token), you cannot get the non-cached users from a server. An HTTP error is thrown, meaning that it's not readily the discord.py API's fault, but the discord gateway or the http server is blocking the request. I believe there must be a way for a user token to grab non-cached users as it does it all the time in the actual app, but likely through Websockets rather than through HTTP sockets, which is why the API throws an error. This feature also doesn't work in discord.NET, JDA or discord.js.

Reproduction Steps

Log into user token, fetch users from each guild
client = discord.Client()
@client.event
async def on_ready():
for guild in client.guilds:
async for member in guild.fetch_users():
print(member.name)

client.run('<a user token>', bot=False)

Expected Results

User1
User2
User3
...

Actual Results

Ignoring exception in on_ready
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/discord/client.py", line 312, in _run_event
await coro(*args, **kwargs)
File "/root/Documents/python/adBot/start.py", line 51, in on_ready
async for member in guild.fetch_members():
File "/usr/local/lib/python3.7/dist-packages/discord/iterators.py", line 86, in __anext__
msg = await self.next()
File "/usr/local/lib/python3.7/dist-packages/discord/iterators.py", line 607, in next
await self.fill_members()
File "/usr/local/lib/python3.7/dist-packages/discord/iterators.py", line 629, in fill_members
data = await self.get_members(self.guild.id, self.retrieve, after)
File "/usr/local/lib/python3.7/dist-packages/discord/http.py", line 221, in request
raise Forbidden(r, data)
discord.errors.Forbidden: 403 FORBIDDEN (error code: 50001): Missing Access

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

System Information

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions