The Mojo SDK authenticates in one of two ways: with an access token supplied on the connection, or with the signin RPC over a stateful WebSocket session.
Access tokens
The access_token field on ConnectOptions is placed in the Authorization header. If the value already starts with Bearer , Basic , or Digest , it is passed through verbatim. Otherwise the SDK treats it as a raw JWT and prepends Bearer .
This is the recommended approach for the HTTP and HTTPS transports.
Signing in with credentials
Over a WebSocket session, you can authenticate with the signin RPC. Credentials are encoded as a CBOR map with CborCodec. On success, signin() stores the returned token on the client for subsequent requests.
Note
Other auth methods
signup(credentials_cbor)creates a new record-access account and signs in.authenticate(token)authenticates the current connection with a token, and stores it on the client.invalidate()clears the current token and invalidates the session.
See the method reference for signin, signup, authenticate, and invalidate.