Closed nxexox closed 5 years ago
Example:
class Bitrix24Client(Bitrix24):
"""
Custom Bitrix24 client for Custom oauth urls.
"""
_oauth_endpoint_template = 'https://{domain}/oauth/{action}/'
_oauth_endpoint_template_tokens = 'https://oauth.bitrix.info/oauth/{action}/'
def _resolve_oauth_endpoint(self, action, query=None, tokens: bool = False) -> str:
"""
Builds an OAuth URL with/out query parameters.
:param str action: str Action name of an OAuth endpoint
:param dict query: dict Query parameters
:param bool tokens: Tokens oauth point?
:return: str OAuth endpoint
:rtype: str
"""
template = self._oauth_endpoint_template
if tokens:
template = self._oauth_endpoint_template_tokens
endpoint = template.format(
domain=self.domain,
action=action
)
if query is not None:
endpoint += '?{}'.format(urlencode(query))
return endpoint
def _request_tokens(self, query) -> dict:
"""
The request handler of an OAuth tokens endpoint.
:param dict query: dict Query parameters
:return: dict Encoded response text
:rtype: dict
"""
url = self._resolve_oauth_endpoint('token', tokens=True)
try:
r = requests.get(url, params=query)
except requests.exceptions.RequestException:
r = None
result = utils.resolve_response(r)
return result
hi @nxexox . thanks for your contribution! please download latest version:
$ pip install bitrix24-python3-client==0.3.4
...and manually add the authentication server hostname as follows during instantiation of a client:
>>> from bitrix24 import Bitrix24
>>> bx24 = Bitrix24('your-domain.bitrix24.com', 'your.client.id', 'your_client_secret', auth_domain='oauth.bitrix.info')
hope it helps. close the issue
Ok, I'll try. Don't you upload it to the git repository yet?
sure. i've just upload the latest changes on github
👍 thanks
Refresh REAME.md please.
Please change Bitrix24 domain for oauth refresh tokens for Box version. https://dev.1c-bitrix.ru/learning/course/?COURSE_ID=99&LESSON_ID=5074 It is described in more detail. It is necessary for the tokens to change the domain to oauth.bitrix.info. I checked, and the truth for the boxed version only works like this.