Skip to content

Commit

Permalink
revert change on clientConfiguration and add token and secret on cata…
Browse files Browse the repository at this point in the history
…log calls to handle protected api
  • Loading branch information
Plopix committed Aug 31, 2023
1 parent 4e03fae commit 18de93a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
5 changes: 5 additions & 0 deletions .changeset/silent-games-call.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@crystallize/import-utilities': patch
---

add token and secret on catalog calls to handle protected api"
29 changes: 14 additions & 15 deletions src/bootstrap-tenant/bootstrapper/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import {
import { createAPICaller } from './utils/api'
import { setOrders } from './orders'
import { setCustomers } from './customers'
import { ClientConfiguration, createClient, createMassCallClient } from '@crystallize/js-api-client'
import { createClient, createMassCallClient } from '@crystallize/js-api-client'
import { getExistingOrders } from './utils/get-all-orders'
import { getExistingCustomers } from './utils/get-all-customers'

Expand Down Expand Up @@ -305,20 +305,17 @@ export class Bootstrapper extends EventEmitter {
: 'api.crystallize.com'
}/${this.context.tenantIdentifier}`

let clientConfig: ClientConfiguration = {
// this is PIM CLIENT only for now....
// we should have this PER client like the following
const client = createClient({
tenantIdentifier: this.context.tenantIdentifier,
tenantId: this.context.tenantId,
accessTokenId: this.PIMAPIManager?.CRYSTALLIZE_ACCESS_TOKEN_ID,
accessTokenSecret: this.PIMAPIManager?.CRYSTALLIZE_ACCESS_TOKEN_SECRET,
origin: this.env === 'dev' ? '-dev.crystallize.digital' : '.crystallize.com',
}
if (`${this.PIMAPIManager?.CRYSTALLIZE_SESSION_ID}`.length > 0) {
clientConfig = {
...clientConfig,
sessionId: this.PIMAPIManager?.CRYSTALLIZE_SESSION_ID,
}
}
const client = createClient(clientConfig)
sessionId: this.PIMAPIManager?.CRYSTALLIZE_SESSION_ID,
origin:
this.env === 'dev' ? '-dev.crystallize.digital' : '.crystallize.com',
})

this.context.client = createMassCallClient(client, {})

Expand All @@ -330,8 +327,9 @@ export class Bootstrapper extends EventEmitter {
},
logLevel: this.config.logLevel,
})
this.catalogueAPIManager.CRYSTALLIZE_STATIC_AUTH_TOKEN =
tenant.staticAuthToken
this.catalogueAPIManager.CRYSTALLIZE_STATIC_AUTH_TOKEN = tenant.staticAuthToken
this.catalogueAPIManager.CRYSTALLIZE_ACCESS_TOKEN_ID = tenant.accessTokenId
this.catalogueAPIManager.CRYSTALLIZE_ACCESS_TOKEN_SECRET = tenant.accessTokenSecret
this.context.callCatalogue = this.catalogueAPIManager.push

// Search
Expand All @@ -342,8 +340,9 @@ export class Bootstrapper extends EventEmitter {
},
logLevel: this.config.logLevel,
})
this.searchAPIManager.CRYSTALLIZE_STATIC_AUTH_TOKEN =
tenant.staticAuthToken
this.searchAPIManager.CRYSTALLIZE_STATIC_AUTH_TOKEN = tenant.staticAuthToken
this.searchAPIManager.CRYSTALLIZE_ACCESS_TOKEN_ID = tenant.accessTokenId
this.searchAPIManager.CRYSTALLIZE_ACCESS_TOKEN_SECRET = tenant.accessTokenSecret
this.context.callSearch = this.searchAPIManager.push

// Orders
Expand Down

0 comments on commit 18de93a

Please sign in to comment.