fix(oauth): add User-Agent header to Reddit token refresh (#2517)

Reddit API requires User-Agent header for all requests including OAuth
token refresh. Without it, requests fail with 403 error after the
initial token expires.

Fixes #1822
This commit is contained in:
lif
2025-12-23 12:09:38 +08:00
committed by GitHub
parent 827dd0466f
commit e0d96e2126
2 changed files with 14 additions and 0 deletions

View File

@@ -214,6 +214,17 @@ describe('OAuth Token Refresh', () => {
const [, requestOptions] = (mockFetch as Mock).mock.calls[0]
expect(requestOptions.headers.Accept).toBe('application/json')
})
it('should include User-Agent header for Reddit requests', async () => {
const refreshToken = 'test_refresh_token'
await refreshOAuthToken('reddit', refreshToken)
const [, requestOptions] = (mockFetch as Mock).mock.calls[0]
expect(requestOptions.headers['User-Agent']).toBe(
'sim-studio/1.0 (https://github.com/simstudioai/sim)'
)
})
})
describe('Error Handling', () => {

View File

@@ -1327,6 +1327,9 @@ function getProviderAuthConfig(provider: string): ProviderAuthConfig {
clientId,
clientSecret,
useBasicAuth: true,
additionalHeaders: {
'User-Agent': 'sim-studio/1.0 (https://github.com/simstudioai/sim)',
},
}
}
case 'wealthbox': {