From b874065c010a422e69aa0629d48c2a3176b7a589 Mon Sep 17 00:00:00 2001 From: Sushil Mall Date: Mon, 30 Nov 2026 20:04:52 +0530 Subject: [PATCH 1/2] Client credential renew token --- README.md | 3 +- api_test/_oauth_smoke.py | 48 ++++++++-- api_test/auth_code_smoke.py | 5 +- api_test/client_credentials_smoke.py | 5 +- api_test/jwt_smoke.py | 5 +- dev-notes.md | 9 ++ ringcentral/platform/auth.py | 37 ++++---- ringcentral/platform/platform.py | 131 +++++++++++++++++++------- ringcentral/platform/platform_test.py | 117 +++++++++++++++++++++++ ringcentral/test/testcase.py | 4 +- 10 files changed, 295 insertions(+), 69 deletions(-) diff --git a/README.md b/README.md index e715e9d..28ea4cb 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,8 @@ print('User loaded ' + res.json().name) ### Client credentials For an app configured for the OAuth client credentials grant, call `login()` with -no arguments. Call `login()` again when the access token expires. +no arguments. The SDK exchanges the client ID and secret for a fresh access token +when a request needs one. Call `platform.refresh()` to renew the token explicitly. ```py from ringcentral import SDK diff --git a/api_test/_oauth_smoke.py b/api_test/_oauth_smoke.py index 5817415..9e68818 100644 --- a/api_test/_oauth_smoke.py +++ b/api_test/_oauth_smoke.py @@ -1,9 +1,14 @@ import json import os +from argparse import ArgumentParser from dotenv import load_dotenv from ringcentral.http.api_exception import ApiException +from ringcentral.platform.events import Events + + +ACCOUNT_PATH = '/restapi/v2/accounts/~' def load_user_config(*extra_required): @@ -16,13 +21,29 @@ def load_user_config(*extra_required): return values -def run_smoke(platform, flow, login): +def renewal_requested(): + parser = ArgumentParser() + parser.add_argument('--test-renewal', action='store_true', help='Simulate access token expiry and verify renewal.') + return parser.parse_args().test_renewal + + +def run_smoke(platform, flow, login, *, test_renewal=False, requires_refresh_token=True): operation = f'{flow} login' try: login() operation = 'Account lookup' - response = platform.get('/restapi/v2/accounts/~') + response = platform.get(ACCOUNT_PATH) account = response.json_dict() + if not isinstance(account, dict) or not account.get('id'): + raise SystemExit('The account response did not contain an account ID.') + + status = response.response().status_code + print(f'{flow} login succeeded. Account lookup returned HTTP {status}.') + print(json.dumps(account, indent=2)) + + if test_renewal: + operation = f'{flow} token renewal' + verify_token_renewal(platform, flow, account['id'], requires_refresh_token) except ApiException as error: http_response = error.api_response().response() status = f' (HTTP {http_response.status_code})' if http_response is not None else '' @@ -30,9 +51,22 @@ def run_smoke(platform, flow, login): except Exception as error: raise SystemExit(f'{operation} failed ({type(error).__name__}).') from None - if not isinstance(account, dict) or not account.get('id'): - raise SystemExit('The account response did not contain an account ID.') - status = response.response().status_code - print(f'{flow} login succeeded. Account lookup returned HTTP {status}.') - print(json.dumps(account, indent=2)) +def verify_token_renewal(platform, flow, account_id, requires_refresh_token): + auth = platform.auth() + if requires_refresh_token and not auth.refresh_token_valid(): + raise SystemExit(f'The {flow} login must return a valid refresh token to test renewal.') + + renewals = [] + on_refresh = renewals.append + platform.on(Events.refreshSuccess, on_refresh) + try: + auth.set_data({'expire_time': 0}) + response = platform.get(ACCOUNT_PATH) + account = response.json_dict() + finally: + platform.off(Events.refreshSuccess, on_refresh) + + if len(renewals) != 1 or not isinstance(account, dict) or account.get('id') != account_id: + raise SystemExit('Expected one token renewal and the same account after simulating expiry.') + print(f'HTTP {response.response().status_code}. Automatic {flow} renewal succeeded.') diff --git a/api_test/auth_code_smoke.py b/api_test/auth_code_smoke.py index 3766c3d..01b934a 100644 --- a/api_test/auth_code_smoke.py +++ b/api_test/auth_code_smoke.py @@ -8,7 +8,7 @@ from ringcentral import SDK -from ._oauth_smoke import load_user_config, run_smoke +from ._oauth_smoke import load_user_config, renewal_requested, run_smoke DEFAULT_REDIRECT_URI = 'http://localhost:5000/oauth2callback' @@ -81,6 +81,7 @@ def log_message(self, format, *args): def main(): + test_renewal = renewal_requested() server, client_id, client_secret = load_user_config() redirect_uri = os.getenv('RC_REDIRECT_URI') or DEFAULT_REDIRECT_URI platform = SDK(client_id, client_secret, server, redirect_uri=redirect_uri).platform() @@ -91,7 +92,7 @@ def login(): code = get_authorization_code(platform, redirect_uri, challenge) platform.login(code=code, verifier=verifier) - run_smoke(platform, 'Authorization-code', login) + run_smoke(platform, 'Authorization-code', login, test_renewal=test_renewal) if __name__ == '__main__': diff --git a/api_test/client_credentials_smoke.py b/api_test/client_credentials_smoke.py index dc31f90..aad70d3 100644 --- a/api_test/client_credentials_smoke.py +++ b/api_test/client_credentials_smoke.py @@ -4,10 +4,11 @@ from ringcentral import SDK -from ._oauth_smoke import run_smoke +from ._oauth_smoke import renewal_requested, run_smoke def main(): + test_renewal = renewal_requested() load_dotenv() server = os.getenv('RINGCENTRAL_SERVER_URL') client_id = os.getenv('RINGCENTRAL_CLIENT_ID') @@ -19,7 +20,7 @@ def main(): ) platform = SDK(client_id, client_secret, server).platform() - run_smoke(platform, 'Client credentials', platform.login) + run_smoke(platform, 'Client credentials', platform.login, test_renewal=test_renewal, requires_refresh_token=False) if __name__ == '__main__': diff --git a/api_test/jwt_smoke.py b/api_test/jwt_smoke.py index 5a2ee92..b14788d 100644 --- a/api_test/jwt_smoke.py +++ b/api_test/jwt_smoke.py @@ -1,12 +1,13 @@ from ringcentral import SDK -from ._oauth_smoke import load_user_config, run_smoke +from ._oauth_smoke import load_user_config, renewal_requested, run_smoke def main(): + test_renewal = renewal_requested() server, client_id, client_secret, jwt = load_user_config('RC_JWT') platform = SDK(client_id, client_secret, server).platform() - run_smoke(platform, 'JWT', lambda: platform.login(jwt=jwt)) + run_smoke(platform, 'JWT', lambda: platform.login(jwt=jwt), test_renewal=test_renewal) if __name__ == '__main__': diff --git a/dev-notes.md b/dev-notes.md index de47b97..e8b9ce8 100644 --- a/dev-notes.md +++ b/dev-notes.md @@ -110,6 +110,15 @@ in your shell. uv run --locked python -m api_test.client_credentials_smoke ``` +Add `--test-renewal` to any OAuth smoke command to simulate local access token +expiry and verify that one automatic renewal succeeds and returns the same account. +Client credentials renew through a fresh exchange. JWT and authorization-code +renewal require a valid refresh token from the initial login. + +``` +uv run --locked python -m api_test.client_credentials_smoke --test-renewal +``` + ### JWT and authorization code These tests use the same environment variables as the JavaScript SDK smoke tests. diff --git a/ringcentral/platform/auth.py b/ringcentral/platform/auth.py index 9769ca3..b643a41 100644 --- a/ringcentral/platform/auth.py +++ b/ringcentral/platform/auth.py @@ -1,10 +1,16 @@ from time import time RELEASE_TIMEOUT = 10 +CLIENT_CREDENTIALS = 'client_credentials' +APP_TOKEN_RENEWAL_WINDOW = 60 class Auth: def __init__(self): + self.reset() + + def reset(self): + self.__grant_type = None self.__remember = False self.__token_type = '' @@ -25,6 +31,9 @@ def set_data(self, auth_data=None): if auth_data is None: return self + if 'grant_type' in auth_data or ('access_token' in auth_data and auth_data.get('access_token')): + self.__grant_type = auth_data.get('grant_type') + # Misc if 'remember' in auth_data: @@ -68,7 +77,7 @@ def set_data(self, auth_data=None): return self def data(self): - return { + auth_data = { 'remember': self.__remember, 'token_type': self.__token_type, @@ -84,21 +93,12 @@ def data(self): 'owner_id': self.__owner_id } - def reset(self): - self.__remember = False + if self.__grant_type == CLIENT_CREDENTIALS: + auth_data['grant_type'] = self.__grant_type + return auth_data - self.__token_type = '' - - self.__access_token = '' - self.__expires_in = 0 - self.__expire_time = 0 - - self.__refresh_token = '' - self.__refresh_token_expires_in = 0 - self.__refresh_token_expire_time = 0 - - self.__scope = '' - self.__owner_id = '' + def grant_type(self): + return self.__grant_type def access_token(self): return self.__access_token @@ -110,10 +110,13 @@ def token_type(self): return self.__token_type def access_token_valid(self): - return self.__is_token_date_valid(self.data().get('expire_time')) + if self.__grant_type == CLIENT_CREDENTIALS: + renewal_window = min(APP_TOKEN_RENEWAL_WINDOW, (self.__expires_in or 0) / 2) + return bool(self.__access_token) and self.__expire_time > time() + renewal_window + return self.__is_token_date_valid(self.__expire_time) def refresh_token_valid(self): - return self.__is_token_date_valid(self.data().get('refresh_token_expire_time')) + return self.__is_token_date_valid(self.__refresh_token_expire_time) @staticmethod def __is_token_date_valid(token_date): diff --git a/ringcentral/platform/platform.py b/ringcentral/platform/platform.py index 418bcc6..00ec9de 100644 --- a/ringcentral/platform/platform.py +++ b/ringcentral/platform/platform.py @@ -6,9 +6,14 @@ from urlparse import urlparse from observable import Observable from functools import reduce -from .auth import Auth +from threading import RLock + +from requests import PreparedRequest + +from .auth import Auth, CLIENT_CREDENTIALS from .events import Events from ..core import base64encode +from ..http.api_exception import ApiException import warnings ACCOUNT_ID = '~' @@ -53,6 +58,8 @@ def __init__(self, client, key='', secret='', server='', name='', version='', re self._secret = secret self._client = client self._auth = Auth() + self._auth_lock = RLock() + self._app_token_generation = 0 self._account = ACCOUNT_ID self._known_prefixes = known_prefixes if known_prefixes else KNOWN_PREFIXES self._userAgent = ((self._name + ('/' + self._version if self._version else '') + ' ') if self._name else '') + \ @@ -118,7 +125,8 @@ def logged_in(self): - If any exceptions occur during the process, it returns False. """ try: - return self._auth.access_token_valid() or self.refresh() + with self._auth_lock: + return self._auth.access_token_valid() or self.refresh() except: return False @@ -165,7 +173,7 @@ def login(self, username='', extension='', password='', code='', redirect_uri='' Note: - This method supports password, authorization code, JWT, and client credentials grants. - - Call `login()` again when a client credentials token expires. + - Authenticated requests automatically renew client credentials tokens. - It checks for the presence of required parameters and raises an exception if necessary. - Deprecation warning is issued for username-password login; recommend using JWT or OAuth instead. - Constructs the appropriate request body based on the provided parameters. @@ -202,19 +210,12 @@ def login(self, username='', extension='', password='', code='', redirect_uri='' elif extension or redirect_uri or verifier: raise Exception('Either code, or username with password, or jwt has to be provided') else: - if not self._key or not self._secret: - raise ValueError('Client credentials login requires a client ID and client secret') - body = {'grant_type': 'client_credentials'} - - built_url = self.create_url( TOKEN_ENDPOINT, add_server=True ) - response = self._request_token( built_url, body=body) - auth_data = response.json_dict() - if body['grant_type'] == 'client_credentials': - if not isinstance(auth_data, dict) or not auth_data.get('access_token'): - raise ValueError('Malformed OAuth response: missing access token') - # Use fresh defaults so stored user credentials are cleared on success. - auth_data = Auth().set_data(auth_data).data() - self._auth.set_data(auth_data) + body = {'grant_type': CLIENT_CREDENTIALS} + + with self._auth_lock: + token_url = self.create_url(TOKEN_ENDPOINT, add_server=True) + response = self._request_token(token_url, body=body) + self._store_token_response(response, body['grant_type']) self.trigger(Events.loginSuccess, response) return response except Exception as e: @@ -223,7 +224,7 @@ def login(self, username='', extension='', password='', code='', redirect_uri='' def refresh(self): """ - Refreshes the authentication tokens. + Renews the access token using the active session's OAuth grant. Returns: Response: The response object containing refreshed authentication data if successful. @@ -232,21 +233,33 @@ def refresh(self): Exception: If the refresh token has expired or if any error occurs during the refresh process. Note: - - This method checks if the refresh token is still valid using `_auth.refresh_token_valid()`. - - Constructs the request body with the grant type as 'refresh_token' and includes the refresh token. - - Sends the token refresh request using `_request_token` at this '/restapi/oauth/token end point. + - Client credentials sessions repeat the client credentials exchange. + - User sessions use their existing refresh token. - Triggers the refreshSuccess or refreshError event based on the outcome of the refresh attempt. """ try: - if not self._auth.refresh_token_valid(): - raise Exception('Refresh token has expired') - response = self._request_token(TOKEN_ENDPOINT, body={ - 'grant_type': 'refresh_token', - 'refresh_token': self._auth.refresh_token(), - 'access_token_ttl': ACCESS_TOKEN_TTL, - 'refresh_token_ttl': REFRESH_TOKEN_TTL - }) - self._auth.set_data(response.json_dict()) + with self._auth_lock: + client_credentials = self._auth.grant_type() == CLIENT_CREDENTIALS + if client_credentials: + body = {'grant_type': CLIENT_CREDENTIALS} + else: + if not self._auth.refresh_token_valid(): + raise Exception('Refresh token has expired') + body = { + 'grant_type': 'refresh_token', + 'refresh_token': self._auth.refresh_token(), + 'access_token_ttl': ACCESS_TOKEN_TTL, + 'refresh_token_ttl': REFRESH_TOKEN_TTL + } + + try: + response = self._request_token(TOKEN_ENDPOINT, body=body) + self._store_token_response(response, body['grant_type']) + except Exception: + if client_credentials: + self._auth.reset() + self._auth.set_data({'grant_type': CLIENT_CREDENTIALS}) + raise self.trigger(Events.refreshSuccess, response) return response except Exception as e: @@ -270,10 +283,11 @@ def logout(self): - Triggers the logoutSuccess or logoutError event based on the outcome of the logout attempt. """ try: - response = self._request_token(REVOKE_ENDPOINT, body={ - 'token': self._auth.access_token() - }) - self._auth.reset() + with self._auth_lock: + response = self._request_token(REVOKE_ENDPOINT, body={ + 'token': self._auth.access_token() + }) + self._auth.reset() self.trigger(Events.logoutSuccess, response) return response except Exception as e: @@ -294,8 +308,9 @@ def inflate_request(self, request, skip_auth_check=False): - Modifies the request URL using `create_url`, adding the server URL if necessary. """ if not skip_auth_check: - self._ensure_authentication() - request.headers['Authorization'] = self._auth_header() + with self._auth_lock: + self._ensure_authentication() + request.headers['Authorization'] = self._auth_header() request.headers['User-Agent'] = self._userAgent request.headers['X-User-Agent'] = self._userAgent @@ -304,7 +319,39 @@ def inflate_request(self, request, skip_auth_check=False): return request def send_request(self, request, skip_auth_check=False): - return self._client.send(self.inflate_request(request, skip_auth_check=skip_auth_check)) + if skip_auth_check: + return self._client.send(self.inflate_request(request, skip_auth_check=True)) + + with self._auth_lock: + request = self.inflate_request(request, skip_auth_check=False) + app_generation = None + if self._auth.grant_type() == CLIENT_CREDENTIALS: + app_generation = self._app_token_generation + + try: + return self._client.send(request) + except ApiException as error: + api_response = error.api_response() + if app_generation is None or api_response is None: + raise + response = api_response.response() + if response is None or response.status_code != 401: + raise + + prepared = api_response.request() + # In-memory bodies can be replayed without rereading files or consuming streams. + if not isinstance(prepared, PreparedRequest) or not isinstance(prepared.body, (type(None), str, bytes)): + raise + + retry = prepared.copy() + with self._auth_lock: + if self._auth.grant_type() != CLIENT_CREDENTIALS: + raise + if app_generation == self._app_token_generation: + self._auth.set_data({'expire_time': 0}) + self._ensure_authentication() + retry.headers['Authorization'] = self._auth_header() + return self._client.send(retry) def get(self, url, query_params=None, headers=None, skip_auth_check=False): request = self._client.create_request('GET', url, query_params=query_params, headers=headers) @@ -327,6 +374,8 @@ def delete(self, url, body=None, query_params=None, headers=None, skip_auth_chec return self.send_request(request, skip_auth_check=skip_auth_check) def _request_token(self, path='', body=None): + if body and body.get('grant_type') == CLIENT_CREDENTIALS and (not self._key or not self._secret): + raise ValueError('Client credentials login requires a client ID and client secret') headers = { 'Authorization': 'Basic ' + self._api_key(), 'Content-Type': 'application/x-www-form-urlencoded' @@ -334,6 +383,16 @@ def _request_token(self, path='', body=None): request = self._client.create_request('POST', path, body=body, headers=headers) return self.send_request(request, skip_auth_check=True) + def _store_token_response(self, response, grant_type): + auth_data = response.json_dict() + if grant_type == CLIENT_CREDENTIALS: + if not isinstance(auth_data, dict) or not auth_data.get('access_token'): + raise ValueError('Malformed OAuth response: missing access token') + # Replace cached user state only after parsing a usable app token. + auth_data = Auth().set_data({**auth_data, 'grant_type': CLIENT_CREDENTIALS}).data() + self._app_token_generation += 1 + self._auth.set_data(auth_data) + def _api_key(self): return base64encode(self._key + ':' + self._secret) diff --git a/ringcentral/platform/platform_test.py b/ringcentral/platform/platform_test.py index 9104137..ad2e371 100644 --- a/ringcentral/platform/platform_test.py +++ b/ringcentral/platform/platform_test.py @@ -1,10 +1,13 @@ import sys import unittest +from concurrent.futures import ThreadPoolExecutor +from time import time from urllib.parse import parse_qs import requests_mock from .. import SDK +from ..http.api_exception import ApiException from ..test import TestCase from .events import Events @@ -100,6 +103,120 @@ def test_client_credentials_login(self, mock): self.assertEqual('123', platform.get('/restapi/v2/accounts/~').json_dict()['id']) self.assertEqual('Bearer APP_TOKEN', mock.last_request.headers['Authorization']) + def app_token_mock(self, mock, access_token='APP_TOKEN'): + return self.add(mock, 'POST', '/restapi/oauth/token', { + 'access_token': access_token, + 'token_type': 'Bearer', + 'expires_in': 3600, + }) + + def test_restored_app_token_renews_once_for_concurrent_requests(self, mock): + platform = SDK('whatever', 'whatever', 'https://whatever').platform() + self.app_token_mock(mock) + platform.login() + platform.auth().set_data({'expire_time': time() + 30}) + + restored = SDK('whatever', 'whatever', 'https://whatever').platform() + restored.auth().set_data(platform.auth().data()) + renewals = [] + restored.on(Events.refreshSuccess, renewals.append) + token_request = self.app_token_mock(mock, 'RENEWED_APP_TOKEN') + self.add(mock, 'GET', '/restapi/v2/accounts/~', {'id': '123'}) + + with ThreadPoolExecutor(max_workers=2) as executor: + requests = [executor.submit(restored.get, '/restapi/v2/accounts/~') for _ in range(2)] + self.assertEqual(['123', '123'], [request.result().json_dict()['id'] for request in requests]) + + self.assertEqual(1, len(renewals)) + self.assertEqual(1, token_request.call_count) + self.assertEqual({'grant_type': ['client_credentials']}, parse_qs(token_request.last_request.text)) + self.assertEqual('Basic d2hhdGV2ZXI6d2hhdGV2ZXI=', token_request.last_request.headers['Authorization']) + self.assertEqual(['Bearer RENEWED_APP_TOKEN'] * 2, [ + request.headers['Authorization'] for request in mock.request_history if request.method == 'GET' + ]) + + def test_app_request_retries_after_unauthorized(self, mock): + platform = SDK('whatever', 'whatever', 'https://whatever').platform() + self.app_token_mock(mock) + platform.login() + token_request = self.app_token_mock(mock, 'RENEWED_APP_TOKEN') + endpoint = mock.post('https://whatever/restapi/v2/accounts/~/test', [ + {'status_code': 401, 'json': {'message': 'Rejected token'}}, + {'json': {'id': '123'}, 'headers': {'Content-Type': 'application/json'}}, + ]) + + self.assertEqual('123', platform.post('/restapi/v2/accounts/~/test', {'example': 'body'}).json_dict()['id']) + + self.assertEqual(1, token_request.call_count) + self.assertEqual({'grant_type': ['client_credentials']}, parse_qs(token_request.last_request.text)) + self.assertEqual(['Bearer APP_TOKEN', 'Bearer RENEWED_APP_TOKEN'], [ + request.headers['Authorization'] for request in endpoint.request_history + ]) + self.assertEqual([{'example': 'body'}] * 2, [request.json() for request in endpoint.request_history]) + + def test_app_request_retries_only_once_after_unauthorized(self, mock): + platform = SDK('whatever', 'whatever', 'https://whatever').platform() + self.app_token_mock(mock) + platform.login() + token_request = self.app_token_mock(mock, 'RENEWED_APP_TOKEN') + endpoint = self.add(mock, 'GET', '/restapi/v2/accounts/~', {'message': 'Rejected token'}, status=401) + + with self.assertRaises(ApiException): + platform.get('/restapi/v2/accounts/~') + + self.assertEqual(1, token_request.call_count) + self.assertEqual(2, endpoint.call_count) + + def test_app_renewal_failure_can_be_retried_on_a_later_request(self, mock): + platform = SDK('whatever', 'whatever', 'https://whatever').platform() + self.app_token_mock(mock) + platform.login() + platform.auth().set_data({'expire_time': 0}) + errors = [] + platform.on(Events.refreshError, errors.append) + token_request = self.add(mock, 'POST', '/restapi/oauth/token', {'error': 'invalid_client'}, status=401) + endpoint = self.add(mock, 'GET', '/restapi/v2/accounts/~', {'id': '123'}) + + with self.assertRaises(ApiException) as failure: + platform.get('/restapi/v2/accounts/~') + + self.assertEqual(1, token_request.call_count) + self.assertFalse(endpoint.called) + self.assertEqual([failure.exception], errors) + self.assertEqual('', platform.auth().access_token()) + self.app_token_mock(mock, 'RENEWED_APP_TOKEN') + self.assertEqual('123', platform.get('/restapi/v2/accounts/~').json_dict()['id']) + self.assertEqual('Bearer RENEWED_APP_TOKEN', endpoint.last_request.headers['Authorization']) + + def test_refresh_uses_the_grant_for_the_active_session(self, mock): + platform = SDK('whatever', 'whatever', 'https://whatever').platform() + self.app_token_mock(mock) + platform.login() + self.app_token_mock(mock, 'RENEWED_APP_TOKEN') + self.assertEqual('RENEWED_APP_TOKEN', platform.refresh().json_dict()['access_token']) + self.assertEqual({'grant_type': ['client_credentials']}, parse_qs(mock.last_request.text)) + + self.authentication_mock(mock) + platform.login(jwt='jwt-token') + self.assertNotIn('grant_type', platform.auth().data()) + self.refresh_mock(mock) + platform.refresh() + body = parse_qs(mock.last_request.text) + self.assertEqual(['refresh_token'], body['grant_type']) + self.assertEqual(['REFRESH_TOKEN'], body['refresh_token']) + + def test_app_logout_clears_renewal_state(self, mock): + platform = SDK('whatever', 'whatever', 'https://whatever').platform() + token_request = self.app_token_mock(mock) + platform.login() + self.logout_mock(mock) + + platform.logout() + + self.assertFalse(platform.logged_in()) + self.assertNotIn('grant_type', platform.auth().data()) + self.assertEqual(1, token_request.call_count) + def test_client_credentials_requires_client_id_and_secret(self, mock): for key, secret in [('', 'secret'), ('key', '')]: with self.subTest(key=key, secret=secret): diff --git a/ringcentral/test/testcase.py b/ringcentral/test/testcase.py index 8f78a24..be69e7c 100644 --- a/ringcentral/test/testcase.py +++ b/ringcentral/test/testcase.py @@ -20,7 +20,7 @@ def get_sdk(self, mock): return sdk def add(self, mock, method, url, body, status=200): - mock.register_uri( + return mock.register_uri( method=method, url='https://whatever' + url, text= '' if body is None else json.dumps(body), @@ -110,4 +110,4 @@ def delete_mock_with_body(self,mock): return self.add(mock, 'DELETE', '/restapi/v2/accounts/~/extensions', {"keepAssetsInInventory": True,"records": [{"id": "123"}]}) def delete_mock_without_body(self,mock): - return self.add(mock, 'DELETE', '/restapi/v2/accounts/~/extensions', body=None) \ No newline at end of file + return self.add(mock, 'DELETE', '/restapi/v2/accounts/~/extensions', body=None) From cd8a64d35f4f3cfb19f69e4c5155c5faa3911a6f Mon Sep 17 00:00:00 2001 From: Sushil Mall Date: Wed, 2 Dec 2026 12:45:21 +0530 Subject: [PATCH 2/2] Version change --- README.md | 2 +- dev-notes.md | 2 +- pyproject.toml | 2 +- uv.lock | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 04b54b5..0ccac45 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ __[Voice](https://developer.ringcentral.com/api-products/voice), [SMS/MMS](https ## Important change logs -### 1.0.0 +### 1.0.1 - The SDK requires CPython 3.11 or later. CI tests CPython 3.11 through 3.15. - WebSocket subscriptions match server responses to requests, report changes after the server confirms them, and prevent duplicate subscription creation. diff --git a/dev-notes.md b/dev-notes.md index 32eb6e9..e854e4c 100644 --- a/dev-notes.md +++ b/dev-notes.md @@ -298,7 +298,7 @@ version below, run the release tests, build both artifacts into a fresh director and check both artifacts with strict Twine validation and the shared verifier. ```sh -release_version=1.0.0 +release_version=1.0.1 release_commit=$(git rev-parse HEAD) && release_dist=$(mktemp -d) && uv sync --locked --python 3.15 && diff --git a/pyproject.toml b/pyproject.toml index 75c6802..e1c0a98 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "ringcentral" -version = "1.0.0" +version = "1.0.1" description = "RingCentral Python SDK" readme = "README.md" authors = [{ name = "Kirill Konshin" }] diff --git a/uv.lock b/uv.lock index 8e0136c..514cfc4 100644 --- a/uv.lock +++ b/uv.lock @@ -892,7 +892,7 @@ wheels = [ [[package]] name = "ringcentral" -version = "1.0.0" +version = "1.0.1" source = { editable = "." } dependencies = [ { name = "certifi" },