Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Einsteigerfragen
    4. POST requests bei der Adapter Entwicklung

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    POST requests bei der Adapter Entwicklung

    This topic has been deleted. Only users with topic management privileges can see it.
    • L
      lonestar2001 last edited by

      Ich bin leider blutiger Anfänger bei der Adapter-Entwicklung und habe daher sehr grundlegende Fragen:

      Ich möchte per https POST-request einen "username" und "password" (gehashed) an eine URL schicken. Aktuell verwende ich dafür Axios.

      1. Was muss ich tun, damit ich das Passwort nicht im Klartext sondern gehashed übermittel? Ich habe dazu nichts gefunden. In dem Pyhton3 Code, den ich Portieren möchte für ioBroker wird die die hashlib verwendet und das Passwort folgendermaßen verschlüsselt:
      passwordHashed = hashlib.sha1(password.encode()).hexdigest()
      
      1. Die URL, die ich versuche zu erreichen ist die "https://www.myidm.at/api/user/login". Hier bekomme ich mit dem folgenden Code allerdings immer ein "AxiosError: Request failed with status code 404". Die baseURL ist allerdings erreichbar. Liegt es an den Headern?
              this.idmApiClient = axios.create({
                  baseURL: 'https://www.myidm.at',
                  timeout: 1000,
                  headers: {
                      'User-Agent': 'IDM App (Android)'
                  },
                  data: {
                      username: this.config.clientLogin, 
                      password: 'abc'
                  },
                  responseType: 'json',
                  responseEncoding: 'utf8',
                  httpsAgent: new https.Agent({
                      rejectUnauthorized: false,
                  })
              });
      
              try {
                  const installations = await this.idmApiClient.post('/api/user/login');
                  this.log.info('Successfully returning Installation repsonse');
                  this.log.debug(`response: ${installations.status}: ${JSON.stringify(installations.data)}`);
              } catch (err) {
                  this.log.error(err);
                  // AxiosError: Request failed with status code 404
              }
      

      Für jeden Suchbegriff, den ihr mir nennen könnt bin ich sehr dankbar

      arteck 1 Reply Last reply Reply Quote 0
      • arteck
        arteck Developer Most Active @lonestar2001 last edited by arteck

        @lonestar2001
        mit der funktion

        const md5 = require('md5');
        
        md5(dein password)
        
        L 1 Reply Last reply Reply Quote 0
        • L
          lonestar2001 @arteck last edited by

          @arteck

          Danke für den Tipp, ich hab es jetzt folgendermaßen gelöst:

          const { createHash, Hash } = require('crypto');
          
          const hash = createHash('sha1');
          const myData = 'Password';
          hash.update(myData);
          this.log.debug('Hash: '+hash.digest('hex'));
          

          Leider kommt mein POST-request nach wie vor nicht durch.
          Die API vom Server ist auch alles andere als hilfreich

          L 1 Reply Last reply Reply Quote 0
          • L
            lonestar2001 @lonestar2001 last edited by

            @lonestar2001
            gelöst.
            Der Server hat die Parameter in dieser Form erwartet:

            const payload = new URLSearchParams();
            payload.append('username',this.config.clientLogin);
            payload.append('password',passwordHashed);
            
            1 Reply Last reply Reply Quote 0
            • First post
              Last post

            Support us

            ioBroker
            Community Adapters
            Donate

            377
            Online

            31.9k
            Users

            80.3k
            Topics

            1.3m
            Posts

            2
            4
            306
            Loading More Posts
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes
            Reply
            • Reply as topic
            Log in to reply
            Community
            Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
            The ioBroker Community 2014-2023
            logo