|
@@ -373,12 +373,18 @@ export async function getValidAccessToken(storeId: string): Promise<string> {
|
|
|
const newExpiresAt = new Date(Date.now() + (newTokenData.expires_in * 1000)).toISOString()
|
|
const newExpiresAt = new Date(Date.now() + (newTokenData.expires_in * 1000)).toISOString()
|
|
|
|
|
|
|
|
// Update store with new tokens
|
|
// Update store with new tokens
|
|
|
|
|
+ // IMPORTANT: Also preserve client credentials in alt_data for backup
|
|
|
await supabase
|
|
await supabase
|
|
|
.from('stores')
|
|
.from('stores')
|
|
|
.update({
|
|
.update({
|
|
|
access_token: newTokenData.access_token,
|
|
access_token: newTokenData.access_token,
|
|
|
refresh_token: newTokenData.refresh_token || store.refresh_token,
|
|
refresh_token: newTokenData.refresh_token || store.refresh_token,
|
|
|
- token_expires_at: newExpiresAt
|
|
|
|
|
|
|
+ token_expires_at: newExpiresAt,
|
|
|
|
|
+ alt_data: {
|
|
|
|
|
+ ...store.alt_data,
|
|
|
|
|
+ client_id: clientId,
|
|
|
|
|
+ client_secret: clientSecret
|
|
|
|
|
+ }
|
|
|
})
|
|
})
|
|
|
.eq('id', storeId)
|
|
.eq('id', storeId)
|
|
|
|
|
|
|
@@ -398,12 +404,19 @@ export async function getValidAccessToken(storeId: string): Promise<string> {
|
|
|
|
|
|
|
|
const expiresAt = new Date(Date.now() + (tokenData.expires_in * 1000)).toISOString()
|
|
const expiresAt = new Date(Date.now() + (tokenData.expires_in * 1000)).toISOString()
|
|
|
|
|
|
|
|
|
|
+ // Update store with new tokens
|
|
|
|
|
+ // IMPORTANT: Also preserve client credentials in alt_data for backup
|
|
|
await supabase
|
|
await supabase
|
|
|
.from('stores')
|
|
.from('stores')
|
|
|
.update({
|
|
.update({
|
|
|
access_token: tokenData.access_token,
|
|
access_token: tokenData.access_token,
|
|
|
refresh_token: tokenData.refresh_token || null,
|
|
refresh_token: tokenData.refresh_token || null,
|
|
|
- token_expires_at: expiresAt
|
|
|
|
|
|
|
+ token_expires_at: expiresAt,
|
|
|
|
|
+ alt_data: {
|
|
|
|
|
+ ...store.alt_data,
|
|
|
|
|
+ client_id: clientId,
|
|
|
|
|
+ client_secret: clientSecret
|
|
|
|
|
+ }
|
|
|
})
|
|
})
|
|
|
.eq('id', storeId)
|
|
.eq('id', storeId)
|
|
|
|
|
|