2.1.2. AuthenticateUser
Implement this function:
- authenticate_user(username: str, password: str) User
Returns an instance of an
User
that includes all necessary data the client program needs to operate on behalf of the already-created user identified byusername
andpassword
. However, raises autil.DropboxError
in the following circumstances:If no user with
username
exists.If the provided
password
is invalid for the givenusername
.If authentication cannot complete due to malicious action, such as an integrity violation.
- Parameters:
username (str) – The username of the user
password (str) – The password of the user
- Returns:
A
User
instance corresponding to the user identified byusername
- Return type:
- Raises:
DropboxError – if an error case occurred
Warning
This function may be called multiple times with the same credentials to obtain multiple, authenticated
User
instances for the same user. Any actions taken by any authenticated instances of the same user must be immediately visible to all otherUser
instances corresponding to that user.For example, let \(u_1\) and \(u_2\) be two instances of the same user running on different machines. Then, if \(u_1\) uploads a file \(F\), \(u_2\) should be able to download \(F\) immediately.
Note
For simplicity, your system does not need to support concurrent operations—that is, we guarantee that individual operations between clients will be performed serially, and you should implement your client with the assumption that no other code will be running at the same time.