Authorization & token (log in to API) - PJanisio/ewelinkApiPhp GitHub Wiki

Gateway

This class is using gateway method to authorize. It is a common way to log in to APIs -> get confirmation (as a token) and than you can use methods and function to operate the devices. That is why API needs your REDIRECT_URL.

the gateway responsible file is gateway.php.

If you configuration data in Constants.php is right, you should see only link to log in to ewelink API:

Authorize ewelinkApiPhp

When you successfully authorized using your email and password, you will see Your TOKEN credentials:


Token Data
Array
(
    [accessToken] => cce4xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    [atExpiredTime] => 1721581445941
    [refreshToken] => 3caxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    [rtExpiredTime] => 1724173445962
)
You will be redirected in 1 second...

And token.json will be saved in your project folder to save token data for future use.

Afterwards you will be redirected to your REDIRECT_URL you have specyfied and you should see:

Token is valid
Token expiry time: 2024-07-21 19:04:05

If you encounter any errors and you can not resolve them yourself - place an Issue.

Next step:

Getting devices and deviceId