Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to access connection auth parameters #1555

Closed
madjaqk opened this issue May 19, 2021 · 1 comment
Closed

How to access connection auth parameters #1555

madjaqk opened this issue May 19, 2021 · 1 comment
Assignees
Labels

Comments

@madjaqk
Copy link

madjaqk commented May 19, 2021

The traditional way to include additional parameters with a Socket.IO connection is with the query option, something like

const socket = io({
  query: {
    token: "abc"
  }
});

This attaches the items as query parameters on the connection URL, so they can be read with flask_socketio by looking at request.args.

However, query parameters can cause unexpected behavior with multiplexed connections (because the connection is recycled, the connection URL, and thus the query parameters, aren't updated). To address this, Socket.io 3.x added an auth option for the connection function:

const socket = io({
  auth: {
    token: "abc"
  }
});

Per the Socket.IO docs, auth values are sent in the CONNECT packet as opposed to the query parameters.

Is there a way to read these auth values with flask_socketio? My apologies if this is documented somewhere, but I haven't been able to find it. Thank you!

Socket.IO notes on the auth parameter

@miguelgrinberg
Copy link
Owner

This change was implemented in the python-socketio package, which receives the auth argument in the connect handler function. But this change has not been implemented in Flask-SocketIO yet. I'll keep this issue open as a reminder to add it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants