Discord Api 401: Unauthorized Error

I'm trying to get audit logs from my server using discord API. I'm sending my authorization token in headers but it's still returning error 401.

My code:

headers = {
    'authorization': AUTH_TOKEN        
}

params = {
    'limit':'50',
    'user_id': USER_ID,
    'action_type': '40',
    'authorization': AUTH_TOKEN
}

r = requests.get(f' params=params)

Output:

{"code": 0, "message": "401: Unauthorized"}

I tried sending user-agent and stuff like that in headers but it doesn't seem to work.

3

1 Answer

If you're using a bot, you must prefix your Authorization header token with 'Bot'

i.e.

headers = {
    'authorization' : 'Bot asdhgaisudg7asd',
}

See

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Alexander Ross

Alexander Ross

Gaming, Esports & Interactive Media Writer

Alexander Ross has covered the video game industry for a decade, writing deep dives on game design, esports tournaments, VR developments, and gaming culture.

Share this article
Twitter Facebook Pinterest