Skip to content

auth

AuthClient(token_file=None, token_key=None, token=None, server_address=default_global_server_address, local_server=None)

Bases: object

Client to find and use auth tokens to access the dynamic annotation framework services.

Parameters:

Name Type Description Default
token_file str

Path to a JSON key:value file holding your auth token. By default, "~/.cloudvolume/secrets/cave-secret.json" (will check deprecated token name "chunkedgraph-secret.json" as well)

None
token_key str

Key for the token in the token_file. By default, "token"

None
token str or None

Direct entry of the token as a string. If provided, overrides the files. If None, attempts to use the file paths.

None
server_address (str, optional)

URL to the auth server. By default, uses a default server address.

default_global_server_address

request_header property

Formatted request header with the specified token

token property writable

Secret token used to authenticate yourself to the Connectome Annotation Versioning Engine services.

get_group_users(group_id)

Get users in a group

Parameters:

Name Type Description Default
group_id int

ID value for a given group

required

Returns:

Type Description
list

List of dicts of user ids. Returns empty list if group does not exist.

get_new_token(open=False, no_text=False)

Currently, returns instructions for getting a new token based on the current settings and saving it to the local environment. New OAuth tokens are currently not able to be retrieved programmatically.

Parameters:

Name Type Description Default
open bool

If True, opens a web browser to the web page where you can generate a new token.

False

get_token(token_key=None)

Load a token with a given key the specified token file

Parameters:

Name Type Description Default
token_key str or None

key in the token file JSON, by default None. If None, uses 'token'.

None

get_tokens()

Get the tokens setup for this users

Returns:

Type Description
list[dict]:

a list of dictionary of tokens, each with the keys "id": the id of this token "token": the token (str) "user_id": the users id (should be your ID)

get_user_information(user_ids)

Get user data.

Parameters:

Name Type Description Default
user_ids list of int

user_ids to look up

required

save_token(token=None, token_key=default_token_key, overwrite=False, token_file=None, switch_token=True, write_to_server_file=True)

Conveniently save a token in the correct format.

After getting a new token by following the instructions in authclient.get_new_token(), you can save it with a fully default configuration by running:

token = 'my_shiny_new_token'

authclient.save_token(token=token)

Now on next load, authclient=AuthClient() will make an authclient instance using this token. If you would like to specify more information about the json file where the token will be stored, see the parameters below.

Parameters:

Name Type Description Default
token str

New token to save, by default None

None
token_key str

Key for the token in the token_file json, by default "token"

default_token_key
overwrite bool

Allow an existing token to be changed, by default False

False
token_file str

Path to the token file, by default None. If None, uses the default file location specified above.

None
switch_token bool

If True, switch the auth client over into using the new token, by default True

True
write_to_server_file bool

If True, will write token to a server specific file to support this machine interacting with multiple auth servers.

True

setup_token(make_new=True, open=True)

Currently, returns instructions for getting your auth token based on the current settings and saving it to the local environment. New OAuth tokens are currently not able to be retrieved programmatically.

Parameters:

Name Type Description Default
make_new bool

If True, will make a new token, else prompt you to open a page to retrieve an existing token.

True
open bool

If True, opens a web browser to the web page where you can retrieve a token.

True