Discuss Scratch

JackK211424
Scratcher
500+ posts

How do you set cloud variables in python using websockets?

Ok.

So far I know this much.

Connect to
wss://clouddata.scratch.mit.edu

with the headers


cookie: scratchsessionsid={enter session id here};
origin: 'https://scratch.mit.edu'

Then, On connection, you must send a handshake.


This is as much as I have understood to connect to the server.
Im going to update it later (If I can understand the rest)

Last edited by JackK211424 (Feb. 28, 2021 15:32:27)


ninjaMAR
Scratcher
1000+ posts

How do you set cloud variables in python using websockets?

JackK211424 wrote:

Ok.

So far I know this much.

Connect to
wss://clouddata.scratch.mit.edu

with the headers


cookie: scratchsessionsid={enter session id here};
origin: 'https://scratch.mit.edu'

Then, On connection, you must send a handshake.


This is as much as I have understood to connect to the server.
Im going to update it later (If I can understand the rest)

Where would I send those headers
9gr
Scratcher
1000+ posts

How do you set cloud variables in python using websockets?

ninjaMAR wrote:

JackK211424 wrote:

Ok.

So far I know this much.

Connect to
wss://clouddata.scratch.mit.edu

with the headers


cookie: scratchsessionsid={enter session id here};
origin: 'https://scratch.mit.edu'

Then, On connection, you must send a handshake.


This is as much as I have understood to connect to the server.
Im going to update it later (If I can understand the rest)

Where would I send those headers
Javascript in python hmmmmm
Chiroyce
Scratcher
1000+ posts

How do you set cloud variables in python using websockets?

ninjaMAR wrote:

I used you and @pufferfish_test code as an example
uhh which one?







April Fools' topics:
New Buildings in Scratch's headquarters
Give every Scratcher an M1 MacBook Air
Scratch should let users edit other Scratchers' projects
Make a statue for Jeffalo
Scratch Tech Tips™
Make a Chiroyce statue emoji


<img src=“x” onerror=“alert('XSS vulnerability discovered')”>

this is a test sentence
ninjaMAR
Scratcher
1000+ posts

How do you set cloud variables in python using websockets?

Chiroyce wrote:

ninjaMAR wrote:

I used you and @pufferfish_test code as an example
uhh which one?
https://scratch.mit.edu/discuss/topic/483540/?page=2#post-4938959
Chiroyce
Scratcher
1000+ posts

How do you set cloud variables in python using websockets?

ninjaMAR wrote:

Chiroyce wrote:

ninjaMAR wrote:

I used you and @pufferfish_test code as an example
uhh which one?
https://scratch.mit.edu/discuss/topic/483540/?page=2#post-4938959
Ah ok







April Fools' topics:
New Buildings in Scratch's headquarters
Give every Scratcher an M1 MacBook Air
Scratch should let users edit other Scratchers' projects
Make a statue for Jeffalo
Scratch Tech Tips™
Make a Chiroyce statue emoji


<img src=“x” onerror=“alert('XSS vulnerability discovered')”>

this is a test sentence
Sheep_maker
Scratcher
1000+ posts

How do you set cloud variables in python using websockets?

Presumably you'd send your credentials in a Cookie header; according to the documentation, you can pass in a dict to the `extra_headers` parameter:
headers = {
  'Cookie': f'scratchsessionid={your_session_id}',
  'Origin': 'https://scratch.mit.edu'
}
async with websockets.connect('wss://clouddata.scratch.mit.edu/', extra_headers=headers) as websocket: 
Headers from here

- Sheep_maker This is a kumquat-free signature. :P
This is my signature. It appears below all my posts. Discuss it on my profile, not the forums. Here's how to make your own.
.postsignature { overflow: auto; } .scratchblocks { overflow-x: auto; overflow-y: hidden; }
ninjaMAR
Scratcher
1000+ posts

How do you set cloud variables in python using websockets?

Sheep_maker wrote:

Presumably you'd send your credentials in a Cookie header; according to the documentation, you can pass in a dict to the `extra_headers` parameter:
headers = {
  'Cookie': f'scratchsessionid={your_session_id}',
  'Origin': 'https://scratch.mit.edu'
}
async with websockets.connect('wss://clouddata.scratch.mit.edu/', extra_headers=headers) as websocket: 
Headers from here
I did it but it doesn't work. This is my code
SansStudios
Scratcher
1000+ posts

How do you set cloud variables in python using websockets?

Bump.

scratchcloud
Click above to check it out! I've worked on it for over a year!























Just like sudden sadness comes hangin' on the breeze
ninjaMAR
Scratcher
1000+ posts

How do you set cloud variables in python using websockets?

ninjaMAR
Scratcher
1000+ posts

How do you set cloud variables in python using websockets?

ninjaMAR wrote:

SansStudios wrote:

Bump.
ninjaMAR
Scratcher
1000+ posts

How do you set cloud variables in python using websockets?

TheCloudDev
Scratcher
100+ posts

How do you set cloud variables in python using websockets?

four duotrigintillion eleven untrigintillion nine hundred ninety-one trigintillion nine hundred fourteen novemvigintillion five hundred forty-seven octovigintillion six hundred thirty septenvigintillion four hundred eighty sexvigintillion sixty-five quinvigintillion fifty-three quattuorvigintillion three hundred eighty-seven trevigintillion seven hundred two duovigintillion four hundred forty-three unvigintillion eight hundred twelve vigintillion six hundred ninety novemdecillion four hundred two octodecillion four hundred eighty-seven septendecillion seven hundred forty-one sexdecillion eight hundred twelve quindecillion two hundred twenty-five quattuordecillion nine hundred fifty-five tredecillion seven hundred thirty-one duodecillion six hundred twenty-two undecillion six hundred fifty-five decillion four hundred fifty-five nonillion seven hundred twenty-three octillion two hundred fifty-eight septillion eight hundred fifty-seven sextillion two hundred forty-eight quintillion five hundred forty-two quadrillion one hundred sixty-one trillion two hundred twenty-two billion two hundred fifty-four million nine hundred eighty-five thousand two hundred sixteen
Possible combinations for SHA-256 hashing. Should be enough? xD (did some maths and this was the answer)

Hi! I'm TheCloudDev
Chiroyce
Scratcher
1000+ posts

How do you set cloud variables in python using websockets?

TheCloudDev wrote:

Possible combinations for SHA-256 hashing. Should be enough? xD (did some maths and this was the answer)
bruh it's used by Facebook Google Apple and Microsoft, how is that not enough?!?







April Fools' topics:
New Buildings in Scratch's headquarters
Give every Scratcher an M1 MacBook Air
Scratch should let users edit other Scratchers' projects
Make a statue for Jeffalo
Scratch Tech Tips™
Make a Chiroyce statue emoji


<img src=“x” onerror=“alert('XSS vulnerability discovered')”>

this is a test sentence
Chiroyce
Scratcher
1000+ posts

How do you set cloud variables in python using websockets?

bump







April Fools' topics:
New Buildings in Scratch's headquarters
Give every Scratcher an M1 MacBook Air
Scratch should let users edit other Scratchers' projects
Make a statue for Jeffalo
Scratch Tech Tips™
Make a Chiroyce statue emoji


<img src=“x” onerror=“alert('XSS vulnerability discovered')”>

this is a test sentence
Sheep_maker
Scratcher
1000+ posts

How do you set cloud variables in python using websockets?

ninjaMAR wrote:

Sheep_maker wrote:

Presumably you'd send your credentials in a Cookie header; according to the documentation, you can pass in a dict to the `extra_headers` parameter:
headers = {
  'Cookie': f'scratchsessionid={your_session_id}',
  'Origin': 'https://scratch.mit.edu'
}
async with websockets.connect('wss://clouddata.scratch.mit.edu/', extra_headers=headers) as websocket: 
Headers from here
I did it but it doesn't work. This is my code
“doesn't work” is a bit vague; how do you know it doesn't work?

- Sheep_maker This is a kumquat-free signature. :P
This is my signature. It appears below all my posts. Discuss it on my profile, not the forums. Here's how to make your own.
.postsignature { overflow: auto; } .scratchblocks { overflow-x: auto; overflow-y: hidden; }
ninjaMAR
Scratcher
1000+ posts

How do you set cloud variables in python using websockets?

Sheep_maker wrote:

ninjaMAR wrote:

Sheep_maker wrote:

Presumably you'd send your credentials in a Cookie header; according to the documentation, you can pass in a dict to the `extra_headers` parameter:
headers = {
  'Cookie': f'scratchsessionid={your_session_id}',
  'Origin': 'https://scratch.mit.edu'
}
async with websockets.connect('wss://clouddata.scratch.mit.edu/', extra_headers=headers) as websocket: 
Headers from here
I did it but it doesn't work. This is my code
“doesn't work” is a bit vague; how do you know it doesn't work?
It doesn't change the cloud variables
Maximouse
Scratcher
1000+ posts

How do you set cloud variables in python using websockets?

ninjaMAR wrote:

It doesn't change the cloud variables
Maybe you forgot ssl=True? I don't think websockets check the URL to determine if it should use a secure connection or not.


This is Maximouse's signature. Learn more about signatures.
Chiroyce
Scratcher
1000+ posts

How do you set cloud variables in python using websockets?

Maximouse wrote:

Maybe you forgot ssl=True? I don't think websockets check the URL to determine if it should use a secure connection or not.
Where should I add that? My code
 
import asyncio, websockets, os
headers = {
  'Cookie': f'scratchsessionid={os.getenv("sessionid")}',
  'Origin': 'https://scratch.mit.edu'
}
async def send():
  data = ['{"name": "handshake", "user": "Chiroyce", "project_id": 501336792}','{"method":"set","user":"Chiroyce","project_id":"501336792","name":"☁ Cloud","value":123456789}']
  async with websockets.connect('wss://clouddata.scratch.mit.edu/',extra_headers=headers) as websocket: 
    for i in data:
      await websocket.send(i)
      #response = await websocket.recv()
      #print(response)
asyncio.get_event_loop().run_until_complete(send())








April Fools' topics:
New Buildings in Scratch's headquarters
Give every Scratcher an M1 MacBook Air
Scratch should let users edit other Scratchers' projects
Make a statue for Jeffalo
Scratch Tech Tips™
Make a Chiroyce statue emoji


<img src=“x” onerror=“alert('XSS vulnerability discovered')”>

this is a test sentence
Danger_script
Scratcher
20 posts

How do you set cloud variables in python using websockets?

ninjaMAR wrote:

How do you set cloud variables in python using websockets?
My code
import asyncio
import websockets
import os
headers = {
  'Cookie': f'scratchsessionid={os.getenv("sessionid")}',
  'Origin': 'https://scratch.mit.edu'
}
async def send():
  data = ['{"name": "handshake", "user": "ninjaMAR", "project_id": 438906671}','{"method":"set","user":"ninjaMAR","project_id":"438906671","name":"☁ Test3","value":123456789}']
  async with websockets.connect('wss://clouddata.scratch.mit.edu/',extra_headers=headers) as websocket: 
    for i in data:
      await websocket.send(i)
      response = await websocket.recv()
      print(response)
asyncio.get_event_loop().run_until_complete(send())
I really do not know when I know how but I can see how.

Hi, I am a undrated scratcher can you plz follow me? I like to code in python and learning HTML, CSS, and javascript. I am a scout so do not be mean to me or anyone.
Plz follow me.

My dad is better than me at coding. When I am learning coding skills from him to get better. my dad knows how to code in java and other hard coding languages that I do not know.


Powered by DjangoBB