OAuth flow Agent Action is not passing Basic Authorization Headers to the token endpoint #7840
Replies: 3 comments 1 reply
-
Maybe related to this code place: |
Beta Was this translation helpful? Give feedback.
-
I'm taking a second look at this, thanks for your report! |
Beta Was this translation helpful? Give feedback.
-
@danny-avila we found and tested a possible fix here: LibreChat/api/server/services/TokenService.js Line 122 in 6488873 ` // Create Basic Auth header const params = new URLSearchParams({ try {
} catch (error) { I think it will be needed also in the refresh token method... |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
What happened?
In a OAuth flow Agent Action is not passing Basic Authorization Headers to the token endpoint after successfully receiving auth code from authorization endpoint.
https://ai.data-business.de/api/actions/okkzXNwmQB_84V7eG-P5Q/oauth/callback?code=F1HoTLJDH9CR4Kiz3EHnQWWJm-DeP1ojEKLsS9t3yE7OGvy8&state=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJub25jZSI6ImNYOGZpNEV5cHhZaHA5LWZpUUo4RyIsInVzZXIiOiI2NjI3OWE0NjMwYmI5NjIyNzA3ZjU0MmQiLCJhY3Rpb25faWQiOiJva2t6WE53bVFCXzg0VjdlRy1QNVEiLCJpYXQiOjE3NDk2NzQ3OTgsImV4cCI6MTc0OTY3NTM5OH0.TWXtyH4_Z-Z7nBH0S5A6QxnZ1_LFqxxzX71Dsq91bqk
Authentication failed. Please try again.
In our Backend OpenAPI endpoint we have traced the request and can see that the Basic Authorization Headers are not passed into the token Endpoint and therefore the token exchange fails with HTTP 401 Unauthorized
We have simulated the oAuth flow succesfully with a small snippet which sets the Authorization headers like this:
// Step 3: Exchange code for token
console.log('\nExchanging code for token...');
const auth = Buffer.from(
${CLIENT_ID}:${CLIENT_SECRET}
).toString('base64');try {
const response = await axios.post(
TOKEN_URL,
new URLSearchParams({
grant_type: 'authorization_code',
code: code,
redirect_uri: REDIRECT_URI
}),
{
headers: {
'Authorization':
Basic ${auth}
,'Content-Type': 'application/x-www-form-urlencoded'
},
httpsAgent: new https.Agent({ rejectUnauthorized: false })
}
);
Could it be that the Basic Auth headers are missing in the librechat Action oAuth flow ?
Version Information
6488873
Steps to Reproduce
What browsers are you seeing the problem on?
Chrome
Relevant log output
Screenshots
No response
Code of Conduct
Beta Was this translation helpful? Give feedback.
All reactions