Skip to content

client.auth

Client to find and use auth tokens to access the other services.

Methods:

Name Description
get_group_users

Get users in a group

get_new_token

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.

get_token

Load a token with a given key the specified token file

get_tokens

Get the tokens setup for this users

get_user_information

Get user data.

save_token

Conveniently save a token in the correct format.

setup_token

Currently, returns instructions for getting your auth token based on the current settings and saving it to the local environment.

Attributes:

Name Type Description
request_header

Formatted request header with the specified token

token

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

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, ignore_readonly=True, local_server=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
ignore_readonly bool

If True, will only attempt to save a token if the directory is writeable.

True
local_server bool

If True, saves the token to the local server file as well.

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