From 942c418ad8f9603c278af9f2312bd48bfc5260db Mon Sep 17 00:00:00 2001 From: Yuta Kasai Date: Tue, 21 Nov 2023 13:07:23 +0900 Subject: [PATCH] ChannelAccessToken client doesn't have to require channel access token (#557) --- .../python-nextgen-custom-client/api_client.mustache | 9 ++++++++- .../asyncio/api_client.mustache | 9 ++++++++- linebot/v3/moduleattach/api_client.py | 2 +- linebot/v3/moduleattach/async_api_client.py | 2 +- linebot/v3/oauth/api_client.py | 1 - linebot/v3/oauth/async_api_client.py | 1 - linebot/v3/webhooks/api_client.py | 1 - linebot/v3/webhooks/async_api_client.py | 1 - 8 files changed, 18 insertions(+), 8 deletions(-) diff --git a/generator/src/main/resources/python-nextgen-custom-client/api_client.mustache b/generator/src/main/resources/python-nextgen-custom-client/api_client.mustache index 811c1d92..8b46e67f 100644 --- a/generator/src/main/resources/python-nextgen-custom-client/api_client.mustache +++ b/generator/src/main/resources/python-nextgen-custom-client/api_client.mustache @@ -67,7 +67,14 @@ class ApiClient(object): self.default_headers = {} if header_name is not None: self.default_headers[header_name] = header_value - self.default_headers['Authorization'] = 'Bearer ' + configuration.access_token + {{#authMethods}} + {{#isBasicBearer}} + self.default_headers['Authorization'] = 'Bearer {{access_token}}' + configuration.access_token + {{/isBasicBearer}} + {{^isBasicBearer}} + self.default_headers['Authorization'] = 'Basic {{access_token}}' + configuration.access_token + {{/isBasicBearer}} + {{/authMethods}} self.cookie = cookie # Set default User-Agent. self.user_agent = f"line-bot-sdk-python/{__version__}" diff --git a/generator/src/main/resources/python-nextgen-custom-client/asyncio/api_client.mustache b/generator/src/main/resources/python-nextgen-custom-client/asyncio/api_client.mustache index 728b0540..f1536295 100644 --- a/generator/src/main/resources/python-nextgen-custom-client/asyncio/api_client.mustache +++ b/generator/src/main/resources/python-nextgen-custom-client/asyncio/api_client.mustache @@ -67,7 +67,14 @@ class AsyncApiClient(object): self.default_headers = {} if header_name is not None: self.default_headers[header_name] = header_value - self.default_headers['Authorization'] = 'Bearer ' + configuration.access_token + {{#authMethods}} + {{#isBasicBearer}} + self.default_headers['Authorization'] = 'Bearer {{access_token}}' + configuration.access_token + {{/isBasicBearer}} + {{^isBasicBearer}} + self.default_headers['Authorization'] = 'Basic {{access_token}}' + configuration.access_token + {{/isBasicBearer}} + {{/authMethods}} self.cookie = cookie # Set default User-Agent. self.user_agent = f"line-bot-sdk-python/{__version__}" diff --git a/linebot/v3/moduleattach/api_client.py b/linebot/v3/moduleattach/api_client.py index 366c8fbd..24ede162 100644 --- a/linebot/v3/moduleattach/api_client.py +++ b/linebot/v3/moduleattach/api_client.py @@ -74,7 +74,7 @@ def __init__(self, configuration=None, header_name=None, header_value=None, self.default_headers = {} if header_name is not None: self.default_headers[header_name] = header_value - self.default_headers['Authorization'] = 'Bearer ' + configuration.access_token + self.default_headers['Authorization'] = 'Basic ' + configuration.access_token self.cookie = cookie # Set default User-Agent. self.user_agent = f"line-bot-sdk-python/{__version__}" diff --git a/linebot/v3/moduleattach/async_api_client.py b/linebot/v3/moduleattach/async_api_client.py index c3599df2..2b9f8fb6 100644 --- a/linebot/v3/moduleattach/async_api_client.py +++ b/linebot/v3/moduleattach/async_api_client.py @@ -74,7 +74,7 @@ def __init__(self, configuration=None, header_name=None, header_value=None, self.default_headers = {} if header_name is not None: self.default_headers[header_name] = header_value - self.default_headers['Authorization'] = 'Bearer ' + configuration.access_token + self.default_headers['Authorization'] = 'Basic ' + configuration.access_token self.cookie = cookie # Set default User-Agent. self.user_agent = f"line-bot-sdk-python/{__version__}" diff --git a/linebot/v3/oauth/api_client.py b/linebot/v3/oauth/api_client.py index 2cf816e3..e423e8a8 100644 --- a/linebot/v3/oauth/api_client.py +++ b/linebot/v3/oauth/api_client.py @@ -74,7 +74,6 @@ def __init__(self, configuration=None, header_name=None, header_value=None, self.default_headers = {} if header_name is not None: self.default_headers[header_name] = header_value - self.default_headers['Authorization'] = 'Bearer ' + configuration.access_token self.cookie = cookie # Set default User-Agent. self.user_agent = f"line-bot-sdk-python/{__version__}" diff --git a/linebot/v3/oauth/async_api_client.py b/linebot/v3/oauth/async_api_client.py index 64c3a5cb..9fe966cf 100644 --- a/linebot/v3/oauth/async_api_client.py +++ b/linebot/v3/oauth/async_api_client.py @@ -74,7 +74,6 @@ def __init__(self, configuration=None, header_name=None, header_value=None, self.default_headers = {} if header_name is not None: self.default_headers[header_name] = header_value - self.default_headers['Authorization'] = 'Bearer ' + configuration.access_token self.cookie = cookie # Set default User-Agent. self.user_agent = f"line-bot-sdk-python/{__version__}" diff --git a/linebot/v3/webhooks/api_client.py b/linebot/v3/webhooks/api_client.py index 97e0795c..26212a51 100644 --- a/linebot/v3/webhooks/api_client.py +++ b/linebot/v3/webhooks/api_client.py @@ -74,7 +74,6 @@ def __init__(self, configuration=None, header_name=None, header_value=None, self.default_headers = {} if header_name is not None: self.default_headers[header_name] = header_value - self.default_headers['Authorization'] = 'Bearer ' + configuration.access_token self.cookie = cookie # Set default User-Agent. self.user_agent = f"line-bot-sdk-python/{__version__}" diff --git a/linebot/v3/webhooks/async_api_client.py b/linebot/v3/webhooks/async_api_client.py index 6b220871..e0e189d1 100644 --- a/linebot/v3/webhooks/async_api_client.py +++ b/linebot/v3/webhooks/async_api_client.py @@ -74,7 +74,6 @@ def __init__(self, configuration=None, header_name=None, header_value=None, self.default_headers = {} if header_name is not None: self.default_headers[header_name] = header_value - self.default_headers['Authorization'] = 'Bearer ' + configuration.access_token self.cookie = cookie # Set default User-Agent. self.user_agent = f"line-bot-sdk-python/{__version__}"