Skip to content
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

Client credentials grant type deprecated #81

Open
arenddeboer opened this issue Jul 13, 2023 · 5 comments
Open

Client credentials grant type deprecated #81

arenddeboer opened this issue Jul 13, 2023 · 5 comments

Comments

@arenddeboer
Copy link

" Authenticate error: unauthorized_client"
It looks like Netatmo has finaly disabled "Client credentials grant type" which was slated for October 2022. (https://dev.netatmo.com/apidocumentation/oauth)

One can generate an app with tokens on the netatmo dev site: https://dev.netatmo.com/apps/createanapp and I made a dirty fork to use this refresh token to request a new authorization_token:
https://github.com/arenddeboer/netatmo/blob/main/netatmo.js

I do wonder how long the refresh token generated on the netatmo dev site is valid, so this solution may not be workable if it expires.

@runbert
Copy link

runbert commented Aug 29, 2023

Hi!
Today I got the " unauthorized_client" error when running my NodeJS app. I tried the code from the fork above and the "unauthorized client" error got away, but I don't understand how to use the API now when a refresh token should be used instead?
How do I get the refresh token?
Should I provide it in the auth object?
I would be really thankful if someone can provide an example of how the auth object should look to work with the new code from the fork, for i.e:

var netatmo = require('netatmo');
var auth = {
"client_id": "testtest",
"client_secret": "Test123123",
"username": "[email protected]",
"password": "test123",
"refresh_token": "token123"
};
var api = new netatmo(auth);

Thanks alot!

@arenddeboer
Copy link
Author

arenddeboer commented Aug 30, 2023

This is how I call it:

const api = new Netatmo({
  client_id: 'clientId',
  client_secret:'clientSecret',
  scope: 'read_station',
  refresh_token: 'refreshToken',
})

It's probably the scope that is missing. I only use read_station, so adjust this as needed.

@arenddeboer
Copy link
Author

Looking into it a bit, the fork skips the authenticate function in favor of authenticate_refresh. authenticate() does some variable initialization like:

scope = args.scope || 'read_station read_thermostat write_thermostat read_camera write_camera access_camera read_presence access_presence read_smokedetector read_homecoach';

@runbert
Copy link

runbert commented Aug 30, 2023

Thanks alot for your quick answer!

It worked!

One of the main issues were that I needed to login to https://dev.netatmo.com/apps/ for the specific app and then use their token generator and generate a Refresh Token. Had a little hard time finding that out...

Thanks again!

@arenddeboer
Copy link
Author

Sorry I totally overlooked your refresh token question. Glad you got it working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants