Announcement

Collapse
No announcement yet.

Authenticate OAuth2 using Username and Password

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Authenticate OAuth2 using Username and Password

    I'm trying Big6 to connect to a API using OAuth2.
    I cant really figure out how to configure a profile in the plugin with the information I have.

    I have been able to connect to the API using powershell and only the information I have, so I know its enough.

    Click image for larger version

Name:	Screenshot 2023-02-03 142749.jpg
Views:	205
Size:	18.4 KB
ID:	1590185

    Now when Configuring a HTTP profile in Big6 for oAuth 2.0, I have to provide:
    ClientID, Client Secret, Scopes, Authorize Url, Token Url and Authentication URL.
    I only have one of those, plus the username and password that dosent have any fields.

    If I enter Token URL, Username as Client ID and password as Client Secret, I get the error "Missing oAuth2 data !"

    Here is a link to the API I'm trying to connect too:
    https://api.zaptec.com/help/index.html


    #2
    oAuth2 is a framework that is being implemented differently by different providers. It is targeting mostly app developers rather than end users as it is a method for an app to grab user information hosted at another app. For example if the gadget store xyz is offering you to sign up with your Amazon account than this is a good example of using oAuth2. The principles of oAuth2 and the implementation by Big6 are explained here in details including two examples based on the free service "discord". I do recommend that you play with the examples reproducing them in your environment to get a better feeling of how oAuth2 does work.

    http://big6.ivanv.com/oauth2-examples/

    After that best is to call zaptec and ask them about their own implementation of oAuth2 and see if it is compatible with Big6.

    Comment


      #3
      I saw the examples, but both were for Discord.
      I know Zaptec is using Swagger / OpenAPI, so the question would rather be if Big6 supports OpenAPI.

      Is there any way to influence future releases to maybe include support for this? I may be waaaay off here, but if I understand it correctly, its only about the name used for the parameters. Like if Client ID and Client Secret were switched out with Username & Password, it would work. I really dont know, I'm not a coder and I know that things never is as simple as it seems..

      My only reason for thinking it would work with other parameters is from my testing with Postman, and this is how I get my token:
      Click image for larger version  Name:	Screenshot_1.jpg Views:	0 Size:	42.7 KB ID:	1590282
      If I choose "Send client credentials in body" vs "Send as Basic Auth header" dosent seem to matter, I still get a valid Access Token thats valid for the next 86400 seconds.

      I've been a postman user for about two hours, so I dont really know much about that either. I just really really want to have information regarding our EV Charger in homeseer and I'm kind of desperate here after trying all kinds of things for the last months.
      With power prices that can be double what they are in california and temperatures outside of about 32F -4F, I'm really trying to turn all stones to save where I can and understand what is using power and when 😐 The EV charger is the last big thing to get inside Homeseer that would really make a difference.

      Comment


        #4
        No Big6 does not support any specific API, OpenAPI included. Big6 is a tool for HomeSeer users to communicate with any API. Big6 doesn't require programming skills, however it requires basic understanding of computer networks, interfaces and protocols.

        OAuth2 is just one of the many authentication methods that can be used with OpenAPI. It is not a requirement of the OpenAPI specification and other authentication methods such as API keys, basic authentication, or JSON Web Tokens (JWT) can also be used. The choice of authentication method will depend on the specific requirements of the API and the use case it is being built for. OpenAPI provides a flexible framework for defining the security aspects of an API, including authentication, and allows for multiple security schemes to be specified for an API.

        Big6 does support all 3 of the above other methods of authentication. One possible route for you could be to see if Zaptec can offer you API with another method of authentication. As I said in an earlier post oAuth2 is mainly for developers and not for end users.

        Comment


          #5
          While I wish you luck with zaptec here are some thoughts along the lines of energy metering.

          1. It is nice (and important) to know where you energy money go. I'm not using it yet but I see that HS4 has some build-in features for that. Of course you have to pair HS4 with current sensors that are spread strategically throughout your home typically in the form of smart power outlets (I hear that they make smart power panels too nowadays). I think (going by memory) that Shelly is one vendor that makes smart power outlets with built-in power metering. Shelly is predominantly European vendor so that it will be easy for you to get them. They report over standard protocol(s) that can be handled by Big6 easily.

          2. As far as Electric Vehicle charging goes it is the last thing you need to track. It is what it is. You need certain energy for certain mileage. The only thing to care of is to charge during time of low energy cost and this feature (scheduler) is available in the car. If you want to save on energy than you drive less or drive like my wife carefully without fast acceleration.

          3. If you are handy and like to do hardware projects it is relatively easy to build your own energy meter that reports to Big6/HS4. You can use cheap sensor like TA 12-100 by Hiletgo and cheap ESP32 microcontroller. Total cost of parts is $17. As always I don't count the sweat equity. If I would count it I would be a rich man today :-)

          Comment


            #6
            Back to your zaptec issue.

            Please remember that Big6 can do everything that Postman can do. So if you manage to get a result with Postman than you could implement everything in HS4 using Big6. Big6 can parse the results (responses by zaptec ) into HS4 devices. Furthermore you can do recurring events with HS4 and Big6. If for example your token expires in 24 hours than you can do a recurring event every 23 hours to get a new token, have Big6 parse the token in HS4 device and use the new token next time you log-in.

            Big6 can do HTTP - GET, PUT, POST and DELETE which is pretty much everything that you need.

            I may sound too theoretical but without a real zaptec account neither myself nor anyone else here can get into any details.

            Comment


              #7
              Thank for your answers risquare. This makes me think theres a way after all 😀

              So yes, I am able to do everything that I want with Postman. But I'm not really sure how to enter the same parameters in Big6, like I show in my screenshot in post 3
              If I can figure that out, I think I will figure out the rest. I had no idea what to do once I had a token, but your latest post explained that pretty well. Thanks

              Comment

              Working...
              X