def test_OAuth2FlowNoRedirectResult_online(self):
     # Test online result
     result_obj = OAuth2FlowNoRedirectResult(ACCESS_TOKEN, ACCOUNT_ID, USER_ID, None, EXPIRES_IN,
                                             SCOPE_LIST)
     assert result_obj.access_token == ACCESS_TOKEN
     assert not result_obj.refresh_token
     assert abs(result_obj.expires_at - EXPIRATION) < EXPIRATION_BUFFER
 def test_OAuth2FlowNoRedirectResult_legacy(self):
     # Test legacy result
     result_obj = OAuth2FlowNoRedirectResult(ACCESS_TOKEN, ACCOUNT_ID, USER_ID, None, None,
                                             SCOPE_LIST)
     assert result_obj.access_token == ACCESS_TOKEN
     assert not result_obj.refresh_token
     assert not result_obj.expires_at
 def test_OAuth2FlowNoRedirectResult_offline(self):
     # Test offline result
     result_obj = OAuth2FlowNoRedirectResult(ACCESS_TOKEN, ACCOUNT_ID, USER_ID,
                                             REFRESH_TOKEN, EXPIRES_IN, SCOPE_LIST)
     assert result_obj.access_token == ACCESS_TOKEN
     assert result_obj.refresh_token == REFRESH_TOKEN
     assert abs(result_obj.expires_at - EXPIRATION) < EXPIRATION_BUFFER
     assert result_obj.account_id == ACCOUNT_ID
     assert result_obj.user_id == USER_ID
     assert result_obj.scope == SCOPE_LIST
Esempio n. 4
0
    def finish(access_token):
        """
        Finish OAuth Implicit Grant flow by verifying token and retrieving account info.
        """
        dbx = dropbox.Dropbox(access_token)
        try:
            res = dbx.users_get_current_account()
        except dropbox.exceptions.DropboxException as exc:
            raise to_maestral_error(exc)

        return OAuth2FlowNoRedirectResult(access_token, res.account_id, "")
    def finish(access_token):
        """
        Finish OAuth Implicit Grant flow by verifying token and retrieving account info.

        :param str access_token: Dropbox API access token.
        :returns: Authentication result containing access token and account id.
        :rtype: :class:`dropbox.oauth.OAuth2FlowNoRedirectResult`
        :raises: :class:`errors.MaestralApiError`
        """
        dbx = dropbox.Dropbox(access_token)
        try:
            res = dbx.users_get_current_account()
        except dropbox.exceptions.DropboxException as exc:
            raise dropbox_to_maestral_error(exc)

        return OAuth2FlowNoRedirectResult(access_token, res.account_id, '')
Esempio n. 6
0
 def test_OAuth2FlowNoRedirectResult_copy(self):
     # Test constructor for copying object
     result_obj = OAuth2FlowNoRedirectResult(ACCESS_TOKEN, ACCOUNT_ID,
                                             USER_ID, REFRESH_TOKEN,
                                             EXPIRATION, SCOPE_LIST)
     assert result_obj.expires_at == EXPIRATION