fix(clients): fall back to env credentials when customer has no per-account creds
This commit is contained in:
@@ -22,8 +22,8 @@ async function resolveCreds(
|
||||
): Promise<{ accessToken: string; pageId: string }> {
|
||||
if (customer) {
|
||||
const creds = await customer.getCredential<FacebookCredentials>('facebook');
|
||||
if (!creds) throw new Error('Facebook not connected for this account');
|
||||
return { accessToken: creds.accessToken, pageId: creds.pageId };
|
||||
if (creds) return { accessToken: creds.accessToken, pageId: creds.pageId };
|
||||
// Fall back to default env credentials when customer has no per-account creds
|
||||
}
|
||||
const account = args.account ?? 'default';
|
||||
const accessToken = getEnvToken(account);
|
||||
|
||||
@@ -24,8 +24,8 @@ async function resolveCreds(
|
||||
): Promise<{ accessToken: string; businessAccountId: string }> {
|
||||
if (customer) {
|
||||
const creds = await customer.getCredential<InstagramCredentials>('instagram');
|
||||
if (!creds) throw new Error('Instagram not connected for this account');
|
||||
return { accessToken: creds.accessToken, businessAccountId: creds.businessAccountId };
|
||||
if (creds) return { accessToken: creds.accessToken, businessAccountId: creds.businessAccountId };
|
||||
// Fall back to default env credentials when customer has no per-account creds
|
||||
}
|
||||
const account = args.account ?? 'default';
|
||||
const accessToken = getEnvToken(account);
|
||||
|
||||
Reference in New Issue
Block a user