mirror of
https://github.com/simstudioai/sim.git
synced 2026-01-09 15:07:55 -05:00
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:
@@ -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', () => {
|
||||
|
||||
@@ -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': {
|
||||
|
||||
Reference in New Issue
Block a user