Oauth2 client credentials keep failing

The Netatmo API is a set of webservices allowing developers and third parties to access Netatmo device's data.
Post Reply
LordTWO
Posts: 1
Joined: 19 Nov 2020, 21:25

Oauth2 client credentials keep failing

Post by LordTWO »

Hi all

I've set up an application on dev.netatmo.com and have retrieved the client_id and client_secret. However, when trying to get hold of the access_token using the client credentials option in Oauth2, I keep getting "400 Bad request" error. I have tried sending this through Postman, but no luck.

The following URL is posted from Postman:
https://api.netatmo.com/oauth2/token?gr ... &username=[email@email.no]&password=[MY_PASSWORD]&scope=read_station

I've doubled and triple checked that my CLIENT_ID, CLIENT_SECRET, username and password is correct. I have even tried resetting the CLIENT_SECRET, but without any luck.

The response is:
{
"error": "invalid_request",
"error_description": "Invalid grant_type parameter or parameter missing"
}

The app in dev.netatmo was created just yesterday, and is set up according to requirements. I have made sure that it is activated.

Any tips or hints on what could be wrong here?
Thanks.
Leslie
Posts: 111
Joined: 12 Feb 2020, 11:07

Re: Oauth2 client credentials keep failing

Post by Leslie »

Hello,

For your first /authorize request, you put infos as URL parameters
For your /token request, needed infos must be set in the Body

It should resolve your issue

Have a good day,
Leslie - Community Manager
ciaran
Posts: 1
Joined: 30 Jan 2021, 01:23
Location: Copenhagen

Re: Oauth2 client credentials keep failing

Post by ciaran »

Hi @LordTWO
Did you get this to work? I am having the same problem.
Johannes_Grunedal
Posts: 1
Joined: 16 Sep 2021, 10:55

Re: Oauth2 client credentials keep failing

Post by Johannes_Grunedal »

Hi!
Had the same problem.
Got it to work with Postman and C# when putting all commands in Body (as suggested).

Example:

Code: Select all

var client = new RestClient("https://api.netatmo.com/oauth2/token");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer xxx");
request.AlwaysMultipartFormData = true;
request.AddParameter("client_id", "xxx");
request.AddParameter("client_secret", "xxx");
request.AddParameter("grant_type", "password");
request.AddParameter("username", "xxx");
request.AddParameter("password", "xxx!");
request.AddParameter("scope", "read_station");
IRestResponse response = client.Execute(request);

var rx = response.Content;
(*) Replace xxx with your settings
Post Reply

Return to “Netatmo API”