wasteof_bot — 6/10/2022, 2:29:37 PM

SOLVED

How to auth to wasteof socketio?

Sample code maybe (js code also will be fine)

My current code: connects to API but idk where and how to authenticate (I have token/session)

import os

os.system("pip install python-socketio[client]")
os.system("clear")
import socketio
sio = socketio.Client()

@sio.event
def dsconnect(data):
  print('I received a message!')
  print(data)


@sio.on('updateMessageCount')
def on_message(data):
  print('I received a message!')
  print(data)

@sio.event
def connect():
  print("I'm connected!")
  #sio.emit('login', {'Authorization': api.token})
  

sio.connect("https://api.wasteof.money/")


♥ 5 ↩ 0 💬 25 comments

comments

live-old:

@non-biased-news @wynd @ankit_anmol you have to emit an “updateUser” message with your token like this:

socket.emit('updateUser',this.token)

(that’s what’s used for wasteof-client v3)

Also does anyone know how to send chat messages because I can’t figure out how to

6/14/2022, 2:15:08 PM
quantum-codes:

I got it working without that

6/14/2022, 2:30:07 PM
live-old:

how

6/14/2022, 2:31:01 PM
quantum-codes:

Jeffalo said me the same as wynd answered

https://beta.wasteof.money/posts/62a7c37b0cdad6f85160e6db

6/14/2022, 2:32:43 PM
quantum-codes:

That link is for code

6/14/2022, 2:32:54 PM
non-biased-news:

I have no idea how to use node.js, I use python.

6/14/2022, 6:17:40 PM
wynd:

What does that do?

6/14/2022, 7:37:53 PM
quantum-codes:

@wasteof_bot

6/13/2022, 3:10:59 PM
non-biased-news:

if you use requests:

connect = requests.get('api.wasteof.money/messages', headers={'Authorization': api.token})

idk what to do for socket bc I’ve never used but the auth token needs to be in the header

6/10/2022, 2:44:03 PM
non-biased-news:

so maybe

sio.connect('https://api.wasteof.money', headers={'Authorization': api.token})

6/10/2022, 2:45:23 PM
wasteof_bot:

Lemme try

6/10/2022, 2:54:01 PM
non-biased-news:

6/10/2022, 7:59:53 PM
quantum-codes:

Not working

6/10/2022, 2:57:03 PM
wynd:

idk python, but try

sio.connect("https://api.wasteof.money/", {
    auth: {
        token: "TOKEN_HERE" 
    }
})
6/10/2022, 2:31:56 PM
quantum-codes:

You can post in js too

6/10/2022, 2:32:39 PM
wynd:
const { io } = require(`socket.io-client`)
io(`https://api.wasteof.money`, {
      auth: {
          token: token
      }
});
6/10/2022, 2:34:26 PM
wynd:

socket = the function

6/10/2022, 2:35:12 PM
quantum-codes:

Thanks. I will try now

6/10/2022, 2:35:50 PM
quantum-codes:

Have you tested it? Doesn't work for me

6/10/2022, 2:38:28 PM
wynd:

I have, whats your code?

6/10/2022, 2:58:23 PM
quantum-codes:

Jeffalo just sent the same thing as you did. I think I cant translate to python :(

6/10/2022, 2:57:42 PM
wynd:

Iĺl try to translate to python, even though Idk python

6/10/2022, 3:01:24 PM
wasteof_bot:

Ok ty :P

6/10/2022, 3:07:08 PM
wasteof_bot:

Oh I’m dumb.. Thank you!! It worked!!!!

6/10/2022, 3:17:50 PM
wasteof_bot:

https://replit.com/@QuantumCodes/Wasteof-money-posting#main.py code

6/10/2022, 3:10:57 PM