3rd Party Tokens - treeben77/3rd-Factor-Auth. GitHub Wiki
All examples are in Python.
If you are a developer and would like to authenticate the user controlling is the account owner, you can use 3rd Party Tokens. 3rd Party Tokens can be generated using the !token <auth code> <reason(optional)>
command. This will generate a unique 24 character code which the user can then provide to you. To receive the data from the token, you can use a HTTP POST Request. Check out this repl for an example, you can use the token 'example'.
token = 'example' #this is the token that you recieved from the user.
request = requests.post("https://3rd-Factor-Auth.treeben77.repl.co/requests", data={'token': str(token)})
print(request.text)
The token 'example' should return:
{"token": "example", "user": "3rd Factor Auth.#8789", "id": "836071220024705066", "time": "2021-05-28 16:00:45.671872", "reason": "None"}
Data | Example | Description |
---|---|---|
token | Q7TnsH5UbARThWnEuPaGWhtN |
This is the token in question, the token you provided. |
user | 3rd Factor Auth.#8789 |
The user that generated the token's name and disriminator. |
id | 836071220024705066 |
The user that generated the token's id. |
time | 2021-05-23 15:26:15.885307 |
The time provided from datetime.now() . |
reason | Hello World!! |
Reffer to Reason. |
Please note: these tokens never expire, for extra security, use Reason and use the time provided in the data to make an expiry time.
You can improve security by adding a reason tag so that that token can only be used on your bot. If you type !token <auth code> "TreeBen77"
it will show a as 'TreeBen77'
. If the user did not add any reason, it will show as 'None'
.
This token has the reason 'Hello World!!'
and was created with this command: '!token <auth code> 'Hello World!!'
{"token": "example", "user": "3rd Factor Auth.#8789", "id": "836071220024705066", "time": "2021-05-28 16:00:45.671872", "reason": "Hello World!!"}
This code should is designed for discord.py.
import discord
import requests, json
prefix = "!"
client = commands.Bot(command_prefix=prefix, intents=discord.Intents().all())
@client.command()
async def verify(ctx, token):
data = json.loads(requests.post("https://3rd-Factor-Auth.treeben77.repl.co/requests", data={'token': str(token)}).text)
if ctx.author.id == int(data['id']):
await ctx.send(f"heya! It's you, {ctx.author} :D")
else:
await ctx.send(f"bruh you fake...")
client.run('') #token not included.
An example of the above after an successful token: