models.py

class openhumans.models.OpenHumansMember(*args, **kwargs)

Data storage, auth, etc. related to an Open Humans member account.

exception DoesNotExist
exception MultipleObjectsReturned
classmethod create(oh_id, data, user=None)

Create an Open Humans member, and corresponding User, if not provided.

Parameters:
  • oh_id – This field is the Openhumans id.
  • data – This field contain data related to access token and refresh token.
  • user – This field’s default value is None.
deauth()

Deauthorize the OpenHumans account.

This does not delete the account locally. If access is needed to the OpenHumans functionality associated with the account after this call the OpenHumansMember would need to be re-authorized.

See also: OPENHUMANS_DELETE_ON_DEAUTH

delete_single_file(file_id=None, file_basename=None)

Deletes a file. Specify file_id or file_basename but not both.

Parameters:
  • file_id – This field is the file id of the file to be deleted.
  • file_basename – This field is the file basename of the file to be deleted. It’s default value is None.
get_access_token(client_id='OPENHUMANS_CLIENT_ID', client_secret='OPENHUMANS_CLIENT_SECRET')

Return access token. Refresh first if necessary.

Parameters:
static get_auth_url()

Gets the authentication url.

classmethod get_create_member(data, user=None)

use the data returned by ohapi.api.oauth2_token_exchange and return an oh_member object

list_files()

List files.

message(subject, message)

Send messages.

Parameters:
  • subject – This field is the subject of the message.
  • message – This field is the message which is to be send.
classmethod oh_code_to_member(code)

Exchange code for token, use this to create and return OpenHumansMember. If a matching OpenHumansMember already exists in db, update and return it.

upload(stream, filename, metadata, file_identifier=None)

Upload file to Open Humans.

openhumans.models.make_unique_username(base)

Ensure a unique username. Probably this never actually gets used.