Examples about oAuth

The Netatmo API is a set of webservices allowing developers and third parties to access Netatmo device's data.
Post Reply
dmolner
Posts: 4
Joined: 11 Jul 2020, 17:58

Examples about oAuth

Post by dmolner » 12 Jul 2020, 08:34

I have serious problems with oAuth.
I'm not a expert programmer.
I tested netatmo GitHub files and not work for me :oops:

I need example about oAuth.

Please help me.

Edited.
I only need download weather stations of my friends

Leslie
Posts: 7
Joined: 12 Feb 2020, 11:07

Re: Examples about oAuth

Post by Leslie » 13 Jul 2020, 08:37

Hello,

First of all, you need to have created a Netatmo account and your own application : https://dev.netatmo.com/apps/
Once done, you need to send a POST request with those parameters (you can copy/paste the URL in your web browser) :

https://api.netatmo.com/oauth2/authoriz ... _SEPARATED]

You will be redirected to a page asking you to accept the scopes. You are now authenticated !

Have a good day,
Leslie - Community Manager

dmolner
Posts: 4
Joined: 11 Jul 2020, 17:58

Re: Examples about oAuth

Post by dmolner » 14 Jul 2020, 11:25

Thank You,

I need more information about redirect_uri.
I download all files from github but not work.
Some page I have page error from web browser.

How file I need for redirect_uri?

I'm checking CLI_WS_API_Example.php
But not work. I put some echo and not appear in the browser

Best regards,

This is part of my code.
$token_url = "https://api.netatmo.net/oauth2/token";
$postdata = http_build_query(
array(
'grant_type' => "password",
'client_id' => $app_id,
'client_secret' => $app_secret,
'username' => $username,
'password' => $password,
'scope' => $scope
)
);
echo "dades adreça<br>";
var_dump($postdata);

$opts = array('http' =>
array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded;charset=UTF-8',
'content' => $postdata
)
);

echo "<br><br>dades adreça final<br>";
var_dump($opts);

$context = stream_context_create($opts);
echo "<br>---".$context."...<br>";
$response = file_get_contents($token_url, false, $context);

Leslie
Posts: 7
Joined: 12 Feb 2020, 11:07

Re: Examples about oAuth

Post by Leslie » 15 Jul 2020, 16:25

Hi,

Did you test this : https://github.com/Netatmo/Netatmo-API-PHP ?
I'm not into integration, but I think you just have do define your redirect_uri in the parameters of your app on https://dev.netatmo.com/apps/

Have a good day,
Leslie - Community Manager

dmolner
Posts: 4
Joined: 11 Jul 2020, 17:58

Re: Examples about oAuth

Post by dmolner » 16 Jul 2020, 10:46

Yes I test this, but not work.

I don't know how to get the connection token.

I send this to https://api.netatmo.com/oauth2/token

Code: Select all

array(1) { ["http"]=> array(3) { ["method"]=> string(4) "POST" ["header"]=> string(47) "Content-type: application/x-www-form-urlencoded" ["content"]=> string(159) "grant_type=password&client_id=___my_client_id___&client_secret=___my_client_secret___&username=___my_email___&password=___my_password___" } }
And the answer is Resource id #2

Post Reply

Return to “Netatmo API”