# Trying to follow discord bot tutorial

**URL:** <https://forum.freecodecamp.org/t/trying-to-follow-discord-bot-tutorial/449804>\
**Category:** Curriculum Help\
**Tags:** python\
**Created:** [March 6, 2021, 2:43am UTC](https://forum.freecodecamp.org/t/trying-to-follow-discord-bot-tutorial/449804 "2021-03-06T02:43:55Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![BiskitBoi509](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/biskitboi509/32/208497_2.png) [@BiskitBoi509](https://forum.freecodecamp.org/u/BiskitBoi509)\
**Post date:** [March 6, 2021, 2:43am UTC](https://forum.freecodecamp.org/t/trying-to-follow-discord-bot-tutorial/449804/1 "2021-03-06T02:43:55Z")

</div>

I should be doing everything correctly, but it comes up with a stupidly long error message. I just started learning coding, so I have no idea what’s going on.

"Traceback (most recent call last):  
File “/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/http.py”, line 293, in static\_login  
data = await self.request(Route(‘GET’, ‘/users/@me’))  
File “/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/http.py”, line 247, in request  
raise HTTPException(r, data)  
discord.errors.HTTPException: 401 Unauthorized (error code: 0): 401: Unauthorized

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

Traceback (most recent call last):  
File “main.py”, line 18, in   
client.run(os.getenv(‘TOKEN’))  
File “/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py”, line 718, in run  
return future.result()  
File “/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py”, line 697, in runner  
await self.start(\*args, \*\*kwargs)  
File “/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py”, line 660, in start  
await self.login(\*args, bot=bot)  
File “/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py”, line 509, in login  
await self.http.static\_login(token.strip(), bot=bot)  
File “/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/http.py”, line 297, in static\_login  
raise LoginFailure(‘Improper token has been passed.’) from exc  
discord.errors.LoginFailure: Improper token has been passed."

---

<div class="post-metadata">

**Author:** ![Naomi](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/naomi/32/422181_2.png) [@Naomi](https://forum.freecodecamp.org/u/Naomi)\
**Post date:** [March 6, 2021, 2:44am UTC](https://forum.freecodecamp.org/t/trying-to-follow-discord-bot-tutorial/449804/2 "2021-03-06T02:44:36Z")

</div>

> [@BiskitBoi509](#):
>
> discord.errors.LoginFailure: Improper token has been passed."

This is your error here. The token you passed is showing invalid.

---

<div class="post-metadata">

**Author:** ![BiskitBoi509](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/biskitboi509/32/208497_2.png) [@BiskitBoi509](https://forum.freecodecamp.org/u/BiskitBoi509)\
**Post date:** [March 6, 2021, 3:14am UTC](https://forum.freecodecamp.org/t/trying-to-follow-discord-bot-tutorial/449804/3 "2021-03-06T03:14:22Z")

</div>

I just check and even regenerated the token and it still shows the same error?

---

<div class="post-metadata">

**Author:** ![Naomi](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/naomi/32/422181_2.png) [@Naomi](https://forum.freecodecamp.org/u/Naomi)\
**Post date:** [March 6, 2021, 5:17am UTC](https://forum.freecodecamp.org/t/trying-to-follow-discord-bot-tutorial/449804/4 "2021-03-06T05:17:17Z")

</div>

What happens if you try to print `os.getenv('TOKEN')`? Does it display your token?

Note: Please don’t share any screenshots or display your token. I just need a yes or no. 🙂

---

<div class="post-metadata">

**Author:** ![BiskitBoi509](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/biskitboi509/32/208497_2.png) [@BiskitBoi509](https://forum.freecodecamp.org/u/BiskitBoi509)\
**Post date:** [March 6, 2021, 6:43pm UTC](https://forum.freecodecamp.org/t/trying-to-follow-discord-bot-tutorial/449804/5 "2021-03-06T18:43:01Z")

</div>

I don’t think so ? 🤷‍♂️

---

<div class="post-metadata">

**Author:** ![benners7](https://avatars.discourse-cdn.com/v4/letter/b/8dc957/32.png) [@benners7](https://forum.freecodecamp.org/u/benners7)\
**Post date:** [March 9, 2021, 3:38am UTC](https://forum.freecodecamp.org/t/trying-to-follow-discord-bot-tutorial/449804/6 "2021-03-09T03:38:03Z")

</div>

I had the same problem, turns out I was using my discord token instead of the bots token. hope this helps you.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/freecodecamp/original/3X/e/1/e1c433102e34b46dfaa3e15d13ab9a514b127078.svg) [@system](https://forum.freecodecamp.org/u/system)\
**Post date:** [September 7, 2021, 3:38pm UTC](https://forum.freecodecamp.org/t/trying-to-follow-discord-bot-tutorial/449804/7 "2021-09-07T15:38:06Z")

</div>

Closed on September 7, 2021, 3:38pm UTC

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.
