-
- Service Provider
- Posts: 45
- Liked: 8 times
- Joined: Apr 24, 2018 1:31 pm
- Full Name: David von Plenker-Tind
- Contact:
Axios post returns 400: unsupported_grant_type
Hi,
We are replacing the deprecated request-promise-native npm package in favor of Axios. Axios works just fine when authenticated, but the authentication itself is not working.
Axios have had issues with application/x-www-form-urlencoded format of the request, but according to several sources on the internet, those issues should be resolved now (current version is 0.27.1).
If I do the authentication request with request-promise-native or Postman I get a token back, so I know that the API is responding as it should.
Is there any way to log requests that are handled by the VBO API? I would like to see what the request looks like when it arrives at the VBO-side, but I can't really find a suitable log for this.
Anyone having successfully used axios for authentication?
We are replacing the deprecated request-promise-native npm package in favor of Axios. Axios works just fine when authenticated, but the authentication itself is not working.
Axios have had issues with application/x-www-form-urlencoded format of the request, but according to several sources on the internet, those issues should be resolved now (current version is 0.27.1).
If I do the authentication request with request-promise-native or Postman I get a token back, so I know that the API is responding as it should.
Is there any way to log requests that are handled by the VBO API? I would like to see what the request looks like when it arrives at the VBO-side, but I can't really find a suitable log for this.
Anyone having successfully used axios for authentication?
Regards,
David von Plenker-Tind
David von Plenker-Tind
-
- Veeam Software
- Posts: 1560
- Liked: 675 times
- Joined: Jul 17, 2015 6:54 pm
- Full Name: Jorge de la Cruz
- Contact:
Re: Axios post returns 400: unsupported_grant_type
Hello David,
I have used extensively bash shell script, and PowerShell to authenticate and extract the info to send it to InfluxDB, etc.
At the moment, VB365 accepts this type of auth:
I have never used Axios, but found a similar question on StackOverflow, with some code snippets:
Once you will have the Bearer, you need to call the rest of the API calls with it, more StackOverflow:
I am not aware of any Log that indicates the API auth fails but will explore it a bit more and come back to you, hope those links are somehow useful.
Let us know.
I have used extensively bash shell script, and PowerShell to authenticate and extract the info to send it to InfluxDB, etc.
At the moment, VB365 accepts this type of auth:
Code: Select all
Request Body:
grant_type=password&username=tech\administrator&password=PassWord1
Let us know.
Jorge de la Cruz
Senior Product Manager | Veeam ONE @ Veeam Software
@jorgedlcruz
https://www.jorgedelacruz.es / https://jorgedelacruz.uk
vExpert 2014-2025 / InfluxAce / Grafana Champion
Senior Product Manager | Veeam ONE @ Veeam Software
@jorgedlcruz
https://www.jorgedelacruz.es / https://jorgedelacruz.uk
vExpert 2014-2025 / InfluxAce / Grafana Champion
-
- Service Provider
- Posts: 45
- Liked: 8 times
- Joined: Apr 24, 2018 1:31 pm
- Full Name: David von Plenker-Tind
- Contact:
Re: Axios post returns 400: unsupported_grant_type
Hi Jorge,
As we do have working authentication with the request-promise-native module in npm, I do not think it really is Veeam that is the issue, but since Axios won't work in conjunction with either
qs.stringify({
grant_type: 'password,
username: 'myusername',
password: 'notsosecret'
});
or
const params = new URLSearchParams();
params.append('grant_type', 'password');
params.append('username', 'myusername');
params.append('password', 'notsosecret');
I thought there was someone else facing this same issue. A log for requests made to the API would also be very helpful in this, as it would mean that I could compare the working request with the one not working.
Currently we are in the process of refactor our entire code base to use Axios (or something else if it turns out that Axios does not work), but this is not super urgent.
As we do have working authentication with the request-promise-native module in npm, I do not think it really is Veeam that is the issue, but since Axios won't work in conjunction with either
qs.stringify({
grant_type: 'password,
username: 'myusername',
password: 'notsosecret'
});
or
const params = new URLSearchParams();
params.append('grant_type', 'password');
params.append('username', 'myusername');
params.append('password', 'notsosecret');
I thought there was someone else facing this same issue. A log for requests made to the API would also be very helpful in this, as it would mean that I could compare the working request with the one not working.
Currently we are in the process of refactor our entire code base to use Axios (or something else if it turns out that Axios does not work), but this is not super urgent.
Regards,
David von Plenker-Tind
David von Plenker-Tind
-
- Product Manager
- Posts: 8225
- Liked: 1337 times
- Joined: Feb 08, 2013 3:08 pm
- Full Name: Mike Resseler
- Location: Belgium
- Contact:
Re: Axios post returns 400: unsupported_grant_type
I will ask the developers if there is a place that this is being logged. Stay tuned
-
- Product Manager
- Posts: 8225
- Liked: 1337 times
- Joined: Feb 08, 2013 3:08 pm
- Full Name: Mike Resseler
- Location: Belgium
- Contact:
Re: Axios post returns 400: unsupported_grant_type
David,
Not really something specific, however, if there would be some information, you should be able to find it in the Veeam.Archiver.REST_DATE_TIME.log
Example of a success:
[27.04.2022 09:02:39] 39 (14996) Authorization started (grant type: UsernamePassword)
[27.04.2022 09:02:40] 39 (14996) Adding new resource (key: 49859b67-6683-4f5e-b3d8-f02fb9d8b61f, pool: ArchiverServerSession)...
[27.04.2022 09:02:40] 39 (14996) ArchiverServerSession pool is not empty
[27.04.2022 09:02:40] 39 (14996) Added new resources to the empty lifetime resource pool: ArchiverServerSession
[27.04.2022 09:02:40] 39 (14996) Authorization succeeded
Example of a failure:
[27.04.2022 09:27:02] 329 (16840) Authorization started (grant type: UsernamePassword)
[27.04.2022 09:27:02] 329 (16840) Error: The server has rejected the client credentials.
[27.04.2022 09:27:02] 329 (16840) Type: System.ServiceModel.Security.SecurityNegotiationException
[27.04.2022 09:27:02] 329 (16840) Stack:.......
Not really something specific, however, if there would be some information, you should be able to find it in the Veeam.Archiver.REST_DATE_TIME.log
Example of a success:
[27.04.2022 09:02:39] 39 (14996) Authorization started (grant type: UsernamePassword)
[27.04.2022 09:02:40] 39 (14996) Adding new resource (key: 49859b67-6683-4f5e-b3d8-f02fb9d8b61f, pool: ArchiverServerSession)...
[27.04.2022 09:02:40] 39 (14996) ArchiverServerSession pool is not empty
[27.04.2022 09:02:40] 39 (14996) Added new resources to the empty lifetime resource pool: ArchiverServerSession
[27.04.2022 09:02:40] 39 (14996) Authorization succeeded
Example of a failure:
[27.04.2022 09:27:02] 329 (16840) Authorization started (grant type: UsernamePassword)
[27.04.2022 09:27:02] 329 (16840) Error: The server has rejected the client credentials.
[27.04.2022 09:27:02] 329 (16840) Type: System.ServiceModel.Security.SecurityNegotiationException
[27.04.2022 09:27:02] 329 (16840) Stack:.......
Who is online
Users browsing this forum: No registered users and 35 guests