<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_tokens(self, auth, username=None):
 """ Returns the tokens owned by the specified user. If no user is specified, uses the user authenticated by ``auth``. :param auth.Authentication auth: authentication for user to retrieve. Must be a username-password authentication, due to a restriction of the Gogs API :param str username: username of owner of tokens :return: list of tokens :rtype: List[Token] :raises NetworkFailure: if there is an error communicating with the server :raises ApiFailure: if the request cannot be serviced """

        if username is None:
            username = self.authenticated_user(auth).username
        response = self.get("/users/{u}/tokens".format(u=username), auth=auth)
        return [Token.from_json(o) for o in response.json()]