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

Quick Fix for #167 #168

Merged
merged 1 commit into from
Jul 19, 2023
Merged

Quick Fix for #167 #168

merged 1 commit into from
Jul 19, 2023

Conversation

TheAxelander
Copy link
Contributor

Extend CredentialManager to accept refresh_token and add warning message for deprecated GenerateToken

Example usage:

var clientId = "myClientId";
var clientSecret = "myClientSecret";
var accessToken = "myAccessToken";
var refreshToken = "myRefreshToken";

var client = new Client(
    SystemClock.Instance, "https://api.netatmo.com/",
    clientId,
    clientSecret);

client.ProvideOAuth2Token(accessToken, refreshToken);
await client.RefreshToken();
var stationsData = await client.Weather.GetStationsData();

@TheAxelander TheAxelander requested a review from Riges as a code owner July 17, 2023 07:21
@TheAxelander
Copy link
Contributor Author

I wrote a small test script to see if it works, below was the output:

Manually provide initial AccessToken & RefreshToken:

AccessToken: ##############
RefreshToken: ##############
ExpiresAt: 2023-07-17T07:23:00Z
ReceivedAt: 2023-07-17T07:22:40Z
**********************************

Request Refresh Token:

AccessToken: ##############
RefreshToken: ##############
ExpiresAt: 2023-07-17T10:22:41Z
ReceivedAt: 2023-07-17T07:22:41Z
**********************************

Livingroom Temperature: 24,2
Office Temperature: 24,8
Outdoor Temperature: 19,6

During init of a Client the token is valid for 20 seconds. After calling RefreshToken() the token gets a validity from the API with 3 hours. I was also able to get my data from Netatmo API.

src/Netatmo/Client.cs Show resolved Hide resolved
@Riges
Copy link
Owner

Riges commented Jul 19, 2023

It will fix #167, I will validate and publish it's.

@Riges Riges merged commit e1d747c into Riges:master Jul 19, 2023
4 checks passed
@TheAxelander TheAxelander deleted the 167_fix_token branch July 19, 2023 11:23
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

Successfully merging this pull request may close these issues.

2 participants