示例#1
0
    def __init__(self, access_token=None):
        self.config = bimdata_api_client.Configuration()
        self.config.host = settings.API_URL
        if access_token:
            # when we have a user access_token
            self.config.access_token = access_token
        else:
            token_payload = {
                "client_id": settings.OIDC_RP_CLIENT_ID,
                "client_secret": settings.OIDC_RP_CLIENT_SECRET,
                "grant_type": "client_credentials",
            }

            # Get the token
            response = requests.post(settings.OIDC_OP_TOKEN_ENDPOINT,
                                     data=token_payload)
            response.raise_for_status()
            self.config.access_token = response.json().get("access_token")

        self.client = bimdata_api_client.ApiClient(self.config)

        self.collaboration_api = bimdata_api_client.CollaborationApi(
            self.client)
        self.ifc_api = bimdata_api_client.IfcApi(self.client)
        self.webhook_api = bimdata_api_client.WebhookApi(self.client)
 def config(self):
     configuration = bimdata_api_client.Configuration()
     configuration.access_token = self.access_token
     configuration.host = self.api_url
     return configuration