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

Unable to get token with 2.0.0 #62

Closed
0rsa opened this issue Jul 17, 2021 · 10 comments
Closed

Unable to get token with 2.0.0 #62

0rsa opened this issue Jul 17, 2021 · 10 comments

Comments

@0rsa
Copy link

0rsa commented Jul 17, 2021

Hello,
v2.0.0
I use credentials.properties correctly filled and I followed instructions provided for this new version (thank you!)
I have this error:

Message: Error during authentication process. Please review your username/password Code: 0 Message: response didn't contains code to get token probably due to an error in authentication process. Response : {"error":"Invalid redirection URI."} Code: 0

Error seems to be related to redirect URI.

I'm still investigating.

Oauth/ViessmannOauthClientImpl.php
l.38
const REDIRECT_URL = "http://localhost:4200/";

@soeffi
Copy link

soeffi commented Jul 17, 2021

Did you make sure, that this redirect URL is set for the client in the developer portal?

@tigermurmel
Copy link

similar issue here!
I created a clientId with no captcha and default URI http://localhost:4200/.
But I get "Error during authentication process. Please review your username/password"

Any Ideas?

@adorobis
Copy link

I've had some problems logging in, instead user name I had to provide e-mail address. Maybe something similar?

@0rsa
Copy link
Author

0rsa commented Jul 17, 2021

I read Viessmann documentation and I'm able now to connect without PHP library.
As viessmann API uses now OAuth, you have to login manually via a Viessman login form, then the form is redirecting you to your redirect_uri.

If you want to avoid that (for an automatic script which refresh every minutes for example), you need to set scope to IoT User offline_access to get a refresh_token which allows to get a fresh token without manual login.

With a simple call, I'm able to retrieve all data from my boiler.

Example of a simple script when u have your refresh_token

$token = json_decode(exec('curl -X POST "https://iam.viessmann.com/idp/v2/token" -H "Content-Type: application/x-www-form-urlencoded" -d "grant_type=refresh_token&client_id=CLIENT_ID&refresh_token=REFRESH_TOKEN"'));

echo exec('curl -X GET https://api.viessmann.com/iot/v1/equipment/installations/INSTALLATION_ID/gateways/GATEWAY_SERIAL/devices/0/features -H "Authorization: Bearer '.$token->access_token.'"');

Viessmann Oauth documentation to get a refresh_token:
https://developer.viessmann.com/en/doc/authentication

@thetrueavatar
Copy link
Owner

thetrueavatar commented Jul 17, 2021 via email

@thetrueavatar
Copy link
Owner

thetrueavatar commented Jul 18, 2021

similar issue here!
I created a clientId with no captcha and default URI http://localhost:4200/.
But I get "Error during authentication process. Please review your username/password"

Any Ideas?

Some people, told me that they did a password recovering to fix the problem. Seems that password with special character lead to some problem. Maybe it's in my implementation but can't check right now.
Did you update the bootstrap.php and the credentials.propeties ? It's required to change both so that the new format of the credentials.properties is correctly managed.

@bidonMarc
Copy link

similar issue here!
I created a clientId with no captcha and default URI http://localhost:4200/.
But I get "Error during authentication process. Please review your username/password"
Any Ideas?

Some people, told me that they did a password recovering to fix the problem. Seems that password with special character lead to some problem. Maybe it's in my implementation but can't check right now.
Did you update the bootstrap.php and the credentials.propeties ? It's required to change both so that the new format of the credentials.properties is correctly managed.

Hi,
I had same issue and I enclosed all the fields with double quote (") to solve it :
user="my.email@gmail.com"
pwd="P4ssword!"
clientId="myAPIkey"

@thetrueavatar
Copy link
Owner

Thanks for the feedback. I will try to fix this to avoid the double quote

@thetrueavatar
Copy link
Owner

I did a fix that should correctly parse php reserved char($,...).
The fix is inside the bootstrap.php for information. Could you check?

@bidonMarc
Copy link

Hi,
I got the following :

pi@rasp-domoticz:/Viessmann-Api/PAC-History$ php getPACValues.php
PHP Warning: include(phar:///home/pi/Viessmann-Api/PAC-History/Viessmann-Api-2.1.0-SNAPSHOT.phar/index.php): failed to open stream: phar error: invalid url or non-existent phar "phar:///home/pi/Viessmann-Api/PAC-History/Viessmann-Api-2.1.0-SNAPSHOT.phar/index.php" in /home/pi/Viessmann-Api/PAC-History/bootstrap.php on line 7
PHP Warning: include(): Failed opening 'phar:///home/pi/Viessmann-Api/PAC-History/Viessmann-Api-2.1.0-SNAPSHOT.phar/index.php' for inclusion (include_path='.:/usr/share/php') in /home/pi/Viessmann-Api/PAC-History/bootstrap.php on line 7
Array
(
[user] => myemail@gmail.com
[pwd] => Passw!qu5
[clientId] => xxxxxxxxxxxxxxx
[installationId] =>
[gatewayId] =>
[deviceId] => 0
[circuitId] => 0
)
Message: Class 'Viessmann\API\ViessmannAPI' not found
Code: 0
pi@rasp-domoticz:
/Viessmann-Api/PAC-History$

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

6 participants