-
-
Notifications
You must be signed in to change notification settings - Fork 10.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FormData autoserialize doesn't work, need to use getBuffer() #5498
Comments
Can you make a successful authorization request with Postman? I suspect their Auth API should use const {data} = await oAuthClient.post(url, {
'client_id': clientId,
'client_secret': clientSecret,
'grant_type': 'client_credentials',
'scope': scope
}, {
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
}); From their docs (https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow#protocol-details):
|
Can I work on this issue? I don't know a lot about this |
@theVJagrawal Before starting work on a fix, it would be a good idea to make sure that the problem really exists in the current version and is not fixed in #5316, which will be released in the next minor version. |
Dose this work? const {data} = await oAuthClient.post(url, new UrlSearchParams({
client_id: clientId,
client_secret: clientSecret,
grant_type: 'client_credentials',
scope: scope
})) |
@jimmywarting that does actually seem to work, thanks. We were migrating from got and were under the impression these params would stay as they were. It might well be user error to be honest, we're not experienced with axios and didn't research it very deeply. |
Good, Most of the http libraries out there supports encoding and understand how to serialize URLSearchParams, FormData, Blob & Files bodies and setting appropriate headers accordingly Guess this can be closed |
Describe the bug
According to the docs you should be able to do a form submit with FormData simply with
await axios.post(url, form, { headers: form.getHeaders() })
. We've been debugging since yesterday and found that this doesn't work, we kept getting error responses from microsoft oauth, until we changed it toawait axios.post(url, form.getBuffer(), { headers: form.getHeaders() });
.To Reproduce
I can't provide a true repro because it depends on an external service and I can't exactly give you our microsoft oauth values. But here's a simple nodejs repl script that demonstrates the problem if you have ms oauth values available. Interestingly, ms oauth responds with a 404 instead of a 400 when the request is malformed.
Code snippet
Expected behavior
No response
Axios Version
1.2.2
Adapter Version
No response
Browser
No response
Browser Version
No response
Node.js Version
16.18.1
OS
No response
Additional Library Versions
Additional context/Screenshots
The text was updated successfully, but these errors were encountered: