How to pass metadata for auth with ray.init

Previously, when connecting to a Kuberay cluster with Basic Authentication, I would do something like:

import ray
import base64

def get_metadata():
    """
    Get authentication header metadata for ray.util.connect
    """
    headers = {"Authorization": f"Basic {base64.b64encode(bytes('my_username:my_password', encoding='ascii')).decode()}"}
    return [(key.lower(), value) for key, value in headers.items()]

ray.util.connect(
    "my-ray-cluster.io:443",
    metadata=get_metadata(),
    secure=True,
)

However, according to the Ray Core 2.0 Changes docs, ray.util.connect is deprecated and I should be using ray.init instead. How do I pass the metadata for Basic Authentication when using ray.init?

@ckw017 could you answer this question about Ray jobs?

On Ray 2.0.0 you should be able to pass it as the _metadata argument and _credentials argument to ray.init, i.e.

ray.init(
   "ray://<your_address>", 
   _metadata=get_metadata(), 
   _credentials=grpc.ssl_channel_credentials()
)