def document_to_dict(document):
    """
    Convert document from mongodb to dict, so that it can be used with google.oauth2.credentials.
    :param document: Document from mongodb.
    :return: Document as dict.
    """
    return {
        'token': document['token'],
        'refresh_token': document['refresh_token'],
        'token_uri': document['token_uri'],
        'client_id': document['client_id'],
        'client_secret': document['client_secret'],
        'scopes': document['scopes'],
    }