Skip to content

Instantly share code, notes, and snippets.

@m-Phoenix852
Created August 26, 2020 07:45
Show Gist options
  • Save m-Phoenix852/b47fffb0fd579bc210420cedbda30b61 to your computer and use it in GitHub Desktop.
Save m-Phoenix852/b47fffb0fd579bc210420cedbda30b61 to your computer and use it in GitHub Desktop.
Simple script to log in to discord account using token.
let token = "your token";
function login(token) {
setInterval(() => {
document.body.appendChild(document.createElement `iframe`).contentWindow.localStorage.token = `"${token}"`
}, 50);
setTimeout(() => {
location.reload();
}, 2500);
}
login(token);
@spekly
Copy link

spekly commented Dec 30, 2024

thanks

@yum1234
Copy link

yum1234 commented Dec 30, 2024

Copy this! there is now a () that covers the iframe.

let token = "your token";

function login(token) {
    setInterval(() => {
        const iframe = document.createElement("iframe");
        document.body.appendChild(iframe);
        iframe.contentWindow.localStorage.token = `${token}`;
    }, 50);

    setTimeout(() => {
        location.reload();
    }, 2500);
}

let token = "your_token_here"; // Replace with your actual token value
login(token);

Tell me if this works, i think it will help everyone else who has been having issues...

@spekly
Copy link

spekly commented Dec 30, 2024

i got an unexpected token error? wait i forgot to paste it in the other spot

@spekly
Copy link

spekly commented Dec 30, 2024

image

@yum1234
Copy link

yum1234 commented Dec 30, 2024

The backticks are missing for ${token}

"Use backticks () for embedding variables or expressions, like ${token}`."

is ur editor like deleting the backticks? try inserting them manually


let token = "your token";


function login(token) {
    setInterval(() => {
        const iframe = document.createElement("iframe");
        document.body.appendChild(iframe);
        iframe.contentWindow.localStorage.token = `${token}`;
    }, 50);

    setTimeout(() => {
        location.reload();
    }, 2500);
}

let token = "your_token_here"; // Replace with your actual token value
login(token);

@spekly
Copy link

spekly commented Dec 30, 2024

they are added now but a new error comes up
image

@pxldevv
Copy link

pxldevv commented Dec 30, 2024

Yeah @yum1234 is correct, your back ticks are being deleted, if this is an unavoidable issue, I have a one line version you can use as a bookmark.

@pxldevv
Copy link

pxldevv commented Dec 30, 2024

@spekly reload, you declared your variable one too many times

@yum1234
Copy link

yum1234 commented Dec 30, 2024

sorry i accidentally pasted let token twice

let token = "your_token_here"; // Replace with your actual token value

function login(token) {
    setInterval(() => {
        const iframe = document.createElement("iframe");
        document.body.appendChild(iframe);
        iframe.contentWindow.localStorage.token = `${token}`;
    }, 50);

    setTimeout(() => {
        location.reload();
    }, 2500);
}


login(token);

@pxldevv
Copy link

pxldevv commented Dec 30, 2024

Oh that makes sense 😄

@spekly
Copy link

spekly commented Dec 30, 2024

it just says this then reloads the page
image

@yum1234
Copy link

yum1234 commented Dec 30, 2024

that means it works! close ur console and u should be logged in

@spekly
Copy link

spekly commented Dec 30, 2024

i mean it refreshes the page and the login screen still stays the same, maybe the token is wrong?

@yum1234
Copy link

yum1234 commented Dec 30, 2024

Did you get your token from the authorization header? And not from local storage? They are different

@spekly
Copy link

spekly commented Dec 30, 2024

how do i get a token from an authorization header?

@yum1234
Copy link

yum1234 commented Dec 30, 2024

Have your developer console open, with it switched to the network tab. Log in normally with your credentials. Do anything, and you will see a bunch of network requests pop up. Click on one of them, and switch to the header tab of the network request. Scroll down to authorization. Copy the string (this is your REAL token). (note if you don't see an authorization header please check a different packet. Send a message too and you will see even more network requests)

image

@spekly
Copy link

spekly commented Dec 30, 2024

do i need to be in my account to get this? im trying to get into my old account and all i have is the token, idk if its from local storage or not

@spekly
Copy link

spekly commented Dec 30, 2024

@yum1234 actually, i think my token IS from my network tab in console. I've tested using the authorization token to log in with the script and it still doesn't work.

@yum1234
Copy link

yum1234 commented Dec 30, 2024

I was in the same boat and to be honest I am not entirely sure. There might be a way to change your token so that its valid. A token is made out of 3 parts. The first part is a user ID. The second part is a timestamp. The third part is a crytographic string representing your username and password. You can very easily get the first and second part. The third part not so much. But if you have the third part, you might be able to manipulate the first and second part.

It seems like discord changed their token structure several times over, and there are many false or i guess old tokens that no longer fit the new system? There isn't much infomation aside from a few advanced programs...

Your old token may contain that third cryptographic part. It is now jsut a matter of modifying it to match the authorization header.

image

@yum1234
Copy link

yum1234 commented Dec 30, 2024

Are you still possibly logged into your old account?

@spekly
Copy link

spekly commented Dec 30, 2024

unfortunately no. but the thing is, even if i use a new discord token (for example, i got the auth token on my main discord not long ago) and paste it within the quotation marks on the script you gave it will reload the page but still nothing will happen, and its the same for the other token aswell.

@yum1234
Copy link

yum1234 commented Dec 30, 2024

DId you follow a tutorial or video on how to get your token? Do you remember the link to it?

@yum1234
Copy link

yum1234 commented Dec 30, 2024

Ok. I have video evidence of this script working 7 days ago on yt for some friends who needed to login by token. This does not work now. wtf?? Can anyone test it on their end? Thanks for alerting it to our attention spekly.

@Techpro709
@spekly

@yum1234
Copy link

yum1234 commented Dec 30, 2024

Ok. After some deep testing

I figured it out. It strongly depends on WHEN you got the token.

I will post a more detailed post later

@yum1234
Copy link

yum1234 commented Dec 30, 2024

Ok. Each time one logins with either the token or actual account credentials, the current token become invalid!!!

I compared the authorization headers after mutiple logins, and yea, they all changed.

You HAVE TO get the new token. Or else if you log out, you won't have that newly generated token.

It looks like there are some common parts for amongst each token: only the end changes. I am assuming that it may represent the timestamp of the new login, and that if you have an old token, you can simply just change that ending to make it like the new token and therefore valid to login with.

If anyone has the expertise to help that would be greatly appreciated!

@spekly
Copy link

spekly commented Dec 30, 2024

what should i change the ending of the old token to?

@pxldevv
Copy link

pxldevv commented Dec 30, 2024

Ok. I have video evidence of this script working 7 days ago on yt for some friends who needed to login by token. This does not work now. wtf?? Can anyone test it on their end? Thanks for alerting it to our attention spekly.

@Techpro709 @spekly

Sure I can test it rq

@pxldevv
Copy link

pxldevv commented Dec 30, 2024

Works perfectly fine.

@pxldevv
Copy link

pxldevv commented Dec 30, 2024

Arc_dsWIoW2hB8.mp4

@yum1234
Copy link

yum1234 commented Dec 30, 2024

If you can, try to login again with the same token; I suspect that the token got invalidated on login and discord has generated a new one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment