Giter Site home page Giter Site logo

Neue Authentifizierung about iobroker.tado HOT 7 CLOSED

Pocki77 avatar Pocki77 commented on June 2, 2024
Neue Authentifizierung

from iobroker.tado.

Comments (7)

Pocki77 avatar Pocki77 commented on June 2, 2024 1

Kein Problem, hier der Link.
https://support.tado.com/en/articles/8565472-how-do-i-update-my-rest-api-authentication-method-to-oauth-2

from iobroker.tado.

HGlab01 avatar HGlab01 commented on June 2, 2024

Danke fürs Sharen der eMail.
Der Adapter verwendet jedoch die Abfrageparameter nicht für die Authentifizierung sondern simple-oauth2
Somit kann meiner Meinung nach die Info aus dem Mail sich nicht auf den ioBroker.tado Adapter beziehen.
Ich selbst nutze den Adapter auch und hab keine E-Mail bekommen

from iobroker.tado.

Pocki77 avatar Pocki77 commented on June 2, 2024

Na, dann ist ja gut. Ich verwende auch nur den IOB-Adapter und die APP. Ich wollte nur Bescheid geben, falls doch was nicht funktioniert. Komisch, das ich dann diese Mail bekommen habe.
Also alles gut.

from iobroker.tado.

HGlab01 avatar HGlab01 commented on June 2, 2024

noch eine Bitte:
Kannst du mir den Link
-Wenn du selbst eine Software geschrieben hast, findest du [in dieser Dokumentation](https://links.tado.com/u/click? eine Anleitung, wie du deine Anfragen richtig authentifizieren kannst.
zu dem Text nochmals so reinkopieren, dass er erhalten bleibt? Oder einfach die Mail weiterleiten an myiobrokeradapters[at]gmail.com

Solche Mails gab es anscheinend auch schon im Nov. 2023 - war ein Fehlalarm
https://community.tado.com/de/discussion/20756/mail-zu-rest-api

from iobroker.tado.

raschy avatar raschy commented on June 2, 2024

@Pocki77 Ich hätte die Anleitung auch gerne gehabt. In weiser voraussicht, falls der Provider meines Adapters auch auf OAuth umsteigt.

from iobroker.tado.

HGlab01 avatar HGlab01 commented on June 2, 2024

@raschy
das kannst dir auch hier ansehen ;-)

Config und lib einbinden:

ioBroker.tado/main.js

Lines 9 to 18 in 3655b04

const tado_config = {
client: {
id: 'tado-web-app',
secret: 'wZaRN7rpjn3FoNyF5IFuxg9uMzYJcvOoQ8QWiIqS3hfk6gLhVlG57j5YNoZL2Rtc',
},
auth: {
tokenHost: tado_auth_url,
}
};
const { ResourceOwnerPassword } = require('simple-oauth2');

Login:

ioBroker.tado/main.js

Lines 1128 to 1140 in 3655b04

async login(username, password) {
const client = new ResourceOwnerPassword(tado_config);
const tokenParams = {
username: username,
password: password,
scope: 'home.user',
};
try {
this.accessToken = await client.getToken(tokenParams);
} catch (error) {
throw new Error('Login failed! Please verify Username and Password');
}
}

Aufruf Login:

ioBroker.tado/main.js

Lines 767 to 770 in 3655b04

// Get login token
try {
step = 'login';
await this.login(user, pass);

Refresh Token (checken ob notwendig und ggf. refreshen)

ioBroker.tado/main.js

Lines 1103 to 1126 in 3655b04

refreshToken() {
const { token } = this.accessToken;
const expirationTimeInSeconds = token.expires_at.getTime() / 1000;
const expirationWindowStart = expirationTimeInSeconds - EXPIRATION_WINDOW_IN_SECONDS;
// If the start of the window has passed, refresh the token
const nowInSeconds = (new Date()).getTime() / 1000;
const shouldRefresh = nowInSeconds >= expirationWindowStart;
return new Promise((resolve, reject) => {
if (shouldRefresh) {
this.accessToken.refresh()
.then(result => {
this.accessToken = result;
resolve(this.accessToken);
})
.catch(error => {
reject(error);
});
} else {
resolve(this.accessToken);
}
});
}

Refresh Token aufrufen vor jedem API Call (Refresh Notwendigkeit wird in der Methode gechecked)

this.refreshToken().then(() => {

Vielleicht hilft's

from iobroker.tado.

raschy avatar raschy commented on June 2, 2024

Danke euch beiden. Ich werde mir das alles mal ansehen. Es müsste eine Adresse geben, wo man das alles gegen testen könnte.

from iobroker.tado.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.