tkausch / MyUplinkSwift

An API client using the MyUplink RESTful API to access NIBE-S heat pump data.
GNU General Public License v3.0
1 stars 1 forks source link

How can I contact you? #1

Closed flopp999 closed 3 years ago

flopp999 commented 3 years ago

Hi I am interested to make a myUplink plug-in for Domoticz. It need to be in python3.

Can I contact you for help? I am stuck to the Bearer token.

I have develop a NibeUplink plug-in for Domoticz and it works.

Thanks

tkausch commented 3 years ago

HI

You currently need clientID and clientSecret to obtain bearer token from withGET /oauth/token service.

Speaking in OAuth2.0 terminology this is a Client Credential Grant:

https://datatracker.ietf.org/doc/html/rfc6749#section-4.4

It is also explained in the my uplink documentation:

https://dev.myuplink.com/auth

An "Authorization Code Grant" would be much more convenient but I did not test if it is supported. You can check the MyUplink Identity services and test if this is supported as well but not documented. I will do the same in the next weeks.

Regards, Thomas Kausch

flopp999 commented 3 years ago

Thanks for reply.

I have tried lots of addresses without getting any idea what is wrong.

I have tried this

curl -v -d "grant_type=authorization_code&client_id=2a12baaa-d77e-4027-baaa-a8f8hvdn6235&client_secret=BCB26DDCD0777777688612HGSUJ3A3&redirect_uri=https://myuplink.com&scope=READSYSTEM&code=21342134" "https://api.myuplink.com/oauth/token" I have change the ID and Secret so they are real ones.

the code=21342134 is just something I tested with.

do you know how to get that Auth code for myUplink?

With NibeUplink you use this link to get the Code

https://api.nibeuplink.com/oauth/authorize?client_id=yyyyyy&scope=READSYSTEM&state=x&redirect_uri=https://api.nibeuplink.com/&response_type=code

This is NibeUplink and it works

https://github.com/flopp999/NIBEUplink-Domoticz

tkausch commented 3 years ago

Hi

Here is the curl call that is working for grant type "client credential":

  curl --request POST \
  --url 'https://api.myuplink.com/oauth/token' \
  --header 'content-type: application/x-www-form-urlencoded' \
  --data grant_type=client_credentials \
  --data client_id='YOUR_CLIENT_ID' \
  --data client_secret='YOUR_CLIENT_SECRET' 

A JSON is returned with token inside. You have to add this Bearer token into HttpHeader for each service call.

  Authorization: Bearer "THE_TOKEN_YoU_GOT"

As said before I did not check if grant type auth-code is working as well.

Cheers, Thomas

flopp999 commented 3 years ago

Thank you sooo much. I now got a Bearer Token :)