<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Thema "Re: To help get started." in Getting started programming with the Viessmann API</title>
    <link>https://community.viessmann.de/t5/Getting-started-programming-with/To-help-get-started/m-p/369199#M443</link>
    <description>&lt;P&gt;Hi &lt;SPAN style="color:var(--ck-color-mention-text);"&gt;&lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://community.viessmann.de/t5/user/viewprofilepage/user-id/74022"&gt;@Steven_G&lt;/a&gt;&lt;/SPAN&gt;&lt;/SPAN&gt; , I quickly checked the code. The only thing that changed should be that we recommend using the v3 of the IDP endpoints. This means you should replace the first to URLs with the following&lt;/P&gt;
&lt;P&gt;&lt;A href="https://iam.viessmann.com/idp/" target="_blank"&gt;https://iam.viessmann.com/idp/&lt;/A&gt;&lt;STRONG&gt;v3&lt;/STRONG&gt;/authorize&lt;/P&gt;
&lt;P&gt;&lt;A href="https://iam.viessmann.com/idp/" target="_blank"&gt;https://iam.viessmann.com/idp/&lt;/A&gt;&lt;STRONG&gt;v3&lt;/STRONG&gt;/token&lt;/P&gt;
&lt;P&gt;Please try it out. In case you still get an error, please post the error here so it is easier to find a solution.&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Michael&lt;/P&gt;</description>
    <pubDate>Thu, 12 Oct 2023 15:05:04 GMT</pubDate>
    <dc:creator>CustomerCareMichael</dc:creator>
    <dc:date>2023-10-12T15:05:04Z</dc:date>
    <item>
      <title>To help get started.</title>
      <link>https://community.viessmann.de/t5/Getting-started-programming-with/To-help-get-started/m-p/181347#M44</link>
      <description>&lt;P&gt;&lt;SPAN class="VIiyi"&gt;&lt;SPAN class="JLqJ4b ChMk0b"&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="VIiyi"&gt;&lt;SPAN class="JLqJ4b ChMk0b"&gt;&lt;SPAN&gt;A simple practice to "get started".&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="VIiyi"&gt;&lt;SPAN class="JLqJ4b ChMk0b"&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="php"&gt;&amp;lt;?php

// Initialization 
//
$authorizeURL = "https://iam.viessmann.com/idp/v2/authorize";
$tokenURL = "https://iam.viessmann.com/idp/v2/token";
$client_id = "Your_Customer_ID"; // API Key
$code_challenge = "47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU";
$callback_uri = "http://localhost:4200/";
$user = "Your_Email"; // The same as used for Vicare 
$pwd = "Your_Password"; // The same as used for Vicare 

// Code parameters 
//
$url = "$authorizeURL?client_id=$client_id&amp;amp;code_challenge=$code_challenge&amp;amp;scope=IoT%20User&amp;amp;redirect_uri=$callback_uri&amp;amp;response_type=code";
$header = array("Content-Type: application/x-www-form-urlencoded");

$curloptions = array(
    CURLOPT_URL =&amp;gt; $url,
    CURLOPT_HTTPHEADER =&amp;gt; $header,
    CURLOPT_SSL_VERIFYPEER =&amp;gt; false,
    CURLOPT_RETURNTRANSFER =&amp;gt; true,
    CURLOPT_USERPWD =&amp;gt; "$user:$pwd",
    CURLOPT_HTTPAUTH =&amp;gt; CURLAUTH_BASIC,
    CURLOPT_POST =&amp;gt; true,
);

// Call Curl Code 
//
$curl = curl_init();
curl_setopt_array($curl, $curloptions);
$response = curl_exec($curl);
curl_close($curl);

// Code Extraction 
//
$matches = array();
$pattern = '/code=(.*)"/';
if (preg_match_all($pattern, $response, $matches)) {
    $code = $matches[1][0];
} else {
    exit("Erreur"."\n");
}

// Token Settings 
//
$url = "$tokenURL?grant_type=authorization_code&amp;amp;code_verifier=$code_challenge&amp;amp;client_id=$client_id&amp;amp;redirect_uri=$callback_uri&amp;amp;code=$code";
$header = array("Content-Type: application/x-www-form-urlencoded");

$curloptions = array(
    CURLOPT_URL =&amp;gt; $url,
    CURLOPT_HTTPHEADER =&amp;gt; $header,
    CURLOPT_SSL_VERIFYPEER =&amp;gt; false,
    CURLOPT_RETURNTRANSFER =&amp;gt; true,
    CURLOPT_HTTPAUTH =&amp;gt; CURLAUTH_BASIC,
    CURLOPT_POST =&amp;gt; true,
);

// Call Curl Token 
//
$curl = curl_init();
curl_setopt_array($curl, $curloptions);
$response = curl_exec($curl);
curl_close($curl);

// Token extraction 
//
$json = json_decode($response, true);
$token = $json['access_token'];

// Read user data 
//
$url = "https://api.viessmann.com/users/v1/users/me?sections=identity";
$header = array("Authorization: Bearer $token");

$curloptions = array(
    CURLOPT_URL =&amp;gt; $url,
    CURLOPT_HTTPHEADER =&amp;gt; $header,
    CURLOPT_SSL_VERIFYPEER =&amp;gt; false,
    CURLOPT_RETURNTRANSFER =&amp;gt; true,
    CURLOPT_HTTPAUTH =&amp;gt; CURLAUTH_BASIC,
);

// Data Curl Call 
//
$curl = curl_init();
curl_setopt_array($curl, $curloptions);
$response = curl_exec($curl);
curl_close($curl);

echo($response);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jul 2021 07:10:20 GMT</pubDate>
      <guid>https://community.viessmann.de/t5/Getting-started-programming-with/To-help-get-started/m-p/181347#M44</guid>
      <dc:creator>nerixs</dc:creator>
      <dc:date>2021-07-21T07:10:20Z</dc:date>
    </item>
    <item>
      <title>Re: To help get started.</title>
      <link>https://community.viessmann.de/t5/Getting-started-programming-with/To-help-get-started/m-p/182299#M49</link>
      <description>&lt;P&gt;&lt;a href="https://community.viessmann.de/t5/user/viewprofilepage/user-id/39193"&gt;@nerixs&lt;/a&gt; , Thanks a lot for sharing a sample code to support others getting started and doing their first API call!&lt;/P&gt;

&lt;P&gt;Much appreciated!&lt;/P&gt;</description>
      <pubDate>Mon, 02 Aug 2021 11:31:42 GMT</pubDate>
      <guid>https://community.viessmann.de/t5/Getting-started-programming-with/To-help-get-started/m-p/182299#M49</guid>
      <dc:creator>CustomerCareMichael</dc:creator>
      <dc:date>2021-08-02T11:31:42Z</dc:date>
    </item>
    <item>
      <title>Betreff: To help get started.</title>
      <link>https://community.viessmann.de/t5/Getting-started-programming-with/To-help-get-started/m-p/185601#M66</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;thanks alot for your sample code. But I am struggling with the easiest things... what exactly is the Client_ID? On my PT2 I can find S/N, ID, S/N from com module... nothing worked.&lt;/P&gt;&lt;P&gt;Do I need to register somewhere to get it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Andi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Sep 2021 19:28:43 GMT</pubDate>
      <guid>https://community.viessmann.de/t5/Getting-started-programming-with/To-help-get-started/m-p/185601#M66</guid>
      <dc:creator>ActionAndi</dc:creator>
      <dc:date>2021-09-06T19:28:43Z</dc:date>
    </item>
    <item>
      <title>Betreff: To help get started.</title>
      <link>https://community.viessmann.de/t5/Getting-started-programming-with/To-help-get-started/m-p/185710#M67</link>
      <description>&lt;P&gt;&lt;A href="https://developer.viessmann.com/en/introduction" target="_blank"&gt;https://developer.viessmann.com/en/introduction&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Sep 2021 19:42:32 GMT</pubDate>
      <guid>https://community.viessmann.de/t5/Getting-started-programming-with/To-help-get-started/m-p/185710#M67</guid>
      <dc:creator>nerixs</dc:creator>
      <dc:date>2021-09-07T19:42:32Z</dc:date>
    </item>
    <item>
      <title>Betreff: To help get started.</title>
      <link>https://community.viessmann.de/t5/Getting-started-programming-with/To-help-get-started/m-p/368950#M442</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Thanks for the code but i am not able to get it run... this Code still works today or did viessmann any changes?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Steven&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2023 05:21:49 GMT</pubDate>
      <guid>https://community.viessmann.de/t5/Getting-started-programming-with/To-help-get-started/m-p/368950#M442</guid>
      <dc:creator>Steven_G</dc:creator>
      <dc:date>2023-10-12T05:21:49Z</dc:date>
    </item>
    <item>
      <title>Re: To help get started.</title>
      <link>https://community.viessmann.de/t5/Getting-started-programming-with/To-help-get-started/m-p/369199#M443</link>
      <description>&lt;P&gt;Hi &lt;SPAN style="color:var(--ck-color-mention-text);"&gt;&lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://community.viessmann.de/t5/user/viewprofilepage/user-id/74022"&gt;@Steven_G&lt;/a&gt;&lt;/SPAN&gt;&lt;/SPAN&gt; , I quickly checked the code. The only thing that changed should be that we recommend using the v3 of the IDP endpoints. This means you should replace the first to URLs with the following&lt;/P&gt;
&lt;P&gt;&lt;A href="https://iam.viessmann.com/idp/" target="_blank"&gt;https://iam.viessmann.com/idp/&lt;/A&gt;&lt;STRONG&gt;v3&lt;/STRONG&gt;/authorize&lt;/P&gt;
&lt;P&gt;&lt;A href="https://iam.viessmann.com/idp/" target="_blank"&gt;https://iam.viessmann.com/idp/&lt;/A&gt;&lt;STRONG&gt;v3&lt;/STRONG&gt;/token&lt;/P&gt;
&lt;P&gt;Please try it out. In case you still get an error, please post the error here so it is easier to find a solution.&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Michael&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2023 15:05:04 GMT</pubDate>
      <guid>https://community.viessmann.de/t5/Getting-started-programming-with/To-help-get-started/m-p/369199#M443</guid>
      <dc:creator>CustomerCareMichael</dc:creator>
      <dc:date>2023-10-12T15:05:04Z</dc:date>
    </item>
    <item>
      <title>Betreff: To help get started.</title>
      <link>https://community.viessmann.de/t5/Getting-started-programming-with/To-help-get-started/m-p/369742#M447</link>
      <description>&lt;P&gt;Hello again,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i tried it with the v3 changes but it still dont work.&lt;/P&gt;&lt;P&gt;I just copied the complete code, edited the $client_id, $user and $pwd part and run it. The response is: "&lt;SPAN&gt;Erreur".&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;No further Error description or something...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Do i have to change another thing in the code? What about the&amp;nbsp;$code_challenge variable?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Best regards&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Oct 2023 17:58:19 GMT</pubDate>
      <guid>https://community.viessmann.de/t5/Getting-started-programming-with/To-help-get-started/m-p/369742#M447</guid>
      <dc:creator>Steven_G</dc:creator>
      <dc:date>2023-10-13T17:58:19Z</dc:date>
    </item>
    <item>
      <title>Re: Betreff: To help get started.</title>
      <link>https://community.viessmann.de/t5/Getting-started-programming-with/To-help-get-started/m-p/370463#M448</link>
      <description>&lt;P&gt;&lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://community.viessmann.de/t5/user/viewprofilepage/user-id/74022"&gt;@Steven_G&lt;/a&gt;&lt;/SPAN&gt; the code verifier / code challenge is a good hint. You could try and use the values from the example in our &lt;A href="https://documentation.viessmann.com/static/authentication" target="_blank"&gt;API Documentation&lt;/A&gt; or use &lt;A href="https://developer.pingidentity.com/en/tools/pkce-code-generator.html" target="_blank"&gt;this tool&lt;/A&gt; to create a code verifier / challenge pair.&lt;/P&gt;
&lt;P&gt;Also, it would make sense to add the additional query parameter &lt;STRONG&gt;&amp;amp;code_challenge_method=S256&lt;/STRONG&gt; to the first call (see our documentation).&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Michael&lt;/P&gt;</description>
      <pubDate>Mon, 16 Oct 2023 07:56:44 GMT</pubDate>
      <guid>https://community.viessmann.de/t5/Getting-started-programming-with/To-help-get-started/m-p/370463#M448</guid>
      <dc:creator>CustomerCareMichael</dc:creator>
      <dc:date>2023-10-16T07:56:44Z</dc:date>
    </item>
    <item>
      <title>Betreff: To help get started.</title>
      <link>https://community.viessmann.de/t5/Getting-started-programming-with/To-help-get-started/m-p/370700#M449</link>
      <description>&lt;P&gt;Thanks for your help.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;from the first call i get an code, the second call to the endpoint tokenURL return&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;{"error":"invalid_grant","error_description":"Invalid grant"}

and the third endpoint (v1/users/me) unauthorized &lt;/SPAN&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Oct 2023 13:38:22 GMT</pubDate>
      <guid>https://community.viessmann.de/t5/Getting-started-programming-with/To-help-get-started/m-p/370700#M449</guid>
      <dc:creator>Steven_G</dc:creator>
      <dc:date>2023-10-16T13:38:22Z</dc:date>
    </item>
    <item>
      <title>Re: Betreff: To help get started.</title>
      <link>https://community.viessmann.de/t5/Getting-started-programming-with/To-help-get-started/m-p/370755#M450</link>
      <description>&lt;P&gt;Please note that the code from the first API call is only valid for 20 seconds. Therefore, you would need to be rather quick in sending the second API call including the code from the first one.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Oct 2023 14:35:33 GMT</pubDate>
      <guid>https://community.viessmann.de/t5/Getting-started-programming-with/To-help-get-started/m-p/370755#M450</guid>
      <dc:creator>CustomerCareMichael</dc:creator>
      <dc:date>2023-10-16T14:35:33Z</dc:date>
    </item>
    <item>
      <title>Re: Betreff: To help get started.</title>
      <link>https://community.viessmann.de/t5/Getting-started-programming-with/To-help-get-started/m-p/370791#M451</link>
      <description>&lt;P&gt;But i use the Code from above so this should not be the Problem i guess... ?&lt;/P&gt;</description>
      <pubDate>Mon, 16 Oct 2023 15:53:01 GMT</pubDate>
      <guid>https://community.viessmann.de/t5/Getting-started-programming-with/To-help-get-started/m-p/370791#M451</guid>
      <dc:creator>Steven_G</dc:creator>
      <dc:date>2023-10-16T15:53:01Z</dc:date>
    </item>
    <item>
      <title>Re: Betreff: To help get started.</title>
      <link>https://community.viessmann.de/t5/Getting-started-programming-with/To-help-get-started/m-p/370967#M452</link>
      <description>&lt;P&gt;Sorry, I thought you were trying the Postman Collection to test the API calls. In this case, you are right the script will do the second call accordingly.&lt;/P&gt;
&lt;P&gt;I noticed that in the second call, the code challenge is also being used as the code verifier. Therefore, two adjustments in the script need to be done:&lt;/P&gt;
&lt;P&gt;1) Change the second call to $url = "$tokenURL?grant_type=authorization_code&amp;amp;code_verifier=&lt;STRONG&gt;$code_verifier&lt;/STRONG&gt;&amp;amp;client_id=$client_id&amp;amp;redirect_uri=$callback_uri&amp;amp;code=$code";&lt;BR /&gt;2) Introduce a new variable in the beginning: &lt;STRONG&gt;$code_verifier = "YOUR CODE VERIFIER"&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;For adjustment 2), you need to put in the code verifier you created via the tool or use the values from our API documentation (see one of my previous posts)&lt;/P&gt;
&lt;P&gt;Please try it and let me know if this works.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 06:15:26 GMT</pubDate>
      <guid>https://community.viessmann.de/t5/Getting-started-programming-with/To-help-get-started/m-p/370967#M452</guid>
      <dc:creator>CustomerCareMichael</dc:creator>
      <dc:date>2023-10-17T06:15:26Z</dc:date>
    </item>
    <item>
      <title>Betreff: To help get started.</title>
      <link>https://community.viessmann.de/t5/Getting-started-programming-with/To-help-get-started/m-p/371163#M453</link>
      <description>&lt;P&gt;It works, thank you very much!&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 10:58:58 GMT</pubDate>
      <guid>https://community.viessmann.de/t5/Getting-started-programming-with/To-help-get-started/m-p/371163#M453</guid>
      <dc:creator>Steven_G</dc:creator>
      <dc:date>2023-10-17T10:58:58Z</dc:date>
    </item>
    <item>
      <title>Betreff: To help get started.</title>
      <link>https://community.viessmann.de/t5/Getting-started-programming-with/To-help-get-started/m-p/425960#M519</link>
      <description>&lt;P&gt;Hi nerixs,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I recently started using Viessmann APIs to get information about my Viessmann devices. Your sample code was really a great support to get my first code running properly - thanks for that!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As I did not yet completely understand the token handling I have the following question:&lt;/P&gt;&lt;P&gt;you are using the code&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;$json = json_decode($response, true);
$token = $json['access_token'];&lt;/PRE&gt;&lt;P&gt;the get the token from the token call. But I cannot see any line in your code where the variable $token is used. Can you give me hint?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards Winfried&lt;/P&gt;</description>
      <pubDate>Sun, 25 Feb 2024 13:05:48 GMT</pubDate>
      <guid>https://community.viessmann.de/t5/Getting-started-programming-with/To-help-get-started/m-p/425960#M519</guid>
      <dc:creator>WSchafmann</dc:creator>
      <dc:date>2024-02-25T13:05:48Z</dc:date>
    </item>
    <item>
      <title>Betreff: To help get started.</title>
      <link>https://community.viessmann.de/t5/Getting-started-programming-with/To-help-get-started/m-p/426321#M520</link>
      <description>&lt;P&gt;Please ignore my question above - I got it &lt;span class="lia-unicode-emoji" title=":zwinkerndes_Gesicht:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Feb 2024 16:36:56 GMT</pubDate>
      <guid>https://community.viessmann.de/t5/Getting-started-programming-with/To-help-get-started/m-p/426321#M520</guid>
      <dc:creator>WSchafmann</dc:creator>
      <dc:date>2024-02-26T16:36:56Z</dc:date>
    </item>
  </channel>
</rss>

