juicejuice / homeassistant_redback

Home Assistant integration for inverter and battery systems from Redback Technologies
7 stars 2 forks source link

Invalid Credentials #4

Closed dereksatgmxcom closed 1 year ago

dereksatgmxcom commented 1 year ago

I have received a link from Redback Technology with my API details.

They provided a 36 character Client ID and a 40 character Credential.

Using these for Redback ID and Redback Authentication result in a message "Invalid Credentials" after a few seconds.

Am I missing a step or using the wrong details?

The credentials do work at https://api.redbacktech.com

My inverter is the SH5000 Smart Hybrid (single phase) with batteries.

juicejuice commented 1 year ago

You have it right - Redback supplied me a "Client ID" of 36 characters (dash separated) and a "Credential" of 40 characters. I use the Client ID in "Redback ID" field and Credential in "Redback Authentication". If you're doing the same then that is what works for myself and the others using this integration. Please check you haven't accidentally included spaces etc.? The integration uses the exact same API methods as the api.redbacktech.com site, so I can't imagine why it wouldn't work.

dereksatgmxcom commented 1 year ago

Thank you for the reply. Using copy/past from notes I opened https://api.redbacktech.com/ to confirm the codes I am using are correct with no problems. Tried again in HA, checking that I had no leading or lagging spaces, still no success. I might start again from scratch, reloading HA and HACS on RPI3. It is sure to be something I have done wrong.

juicejuice commented 1 year ago

OK cool. If the problem persists, let me know what it says in the log? There might be a clue in there.

LachyGoshi commented 1 year ago

Check you are trying to log in to the integration PUBLIC option, not private.

dereksatgmxcom commented 1 year ago

Yes, I am choosing PUBLIC. This message appears in the log file each time I go through the process of Add Integration then choose Redback Technologies. 2023-04-01 17:53:24.365 ERROR (MainThread) [frontend.js.latest.202303091] :0:0 ResizeObserver loop completed with undelivered notifications. There is no other error message associated with Redback. I am starting to wonder if there are different levels of API because logging into https://api.redbacktech.com/ gives me the lock symbol but none of the example seem to show me the current status and output of the inverter.

LachyGoshi commented 1 year ago

I wouldn't be surprised if there are different levels... Like installers have higher access than us.... So there could be other levels also.

Once you log in to the API page, can you run the simple:

Alive GET ​/Api​/v2​/Alive Returns "OK".

Test and get output like in my screenshots?

Screenshot_20230402-193418 Screenshot_20230402-193527

LachyGoshi commented 1 year ago

Screenshot_20230402-193606 apologies, it was struggling to link the screenshots from my phone.

dereksatgmxcom commented 1 year ago

Yes, I see all of that at https://api.redbacktech.com/ I get the green padlock locked. I get the same response from /api/v2/alive But in HA I get "Invalid Authorisation" using exactly the same credentials copy/pasted with no leading or lagging spaces. I have even wiped my HA installation and started from scratch with the same results. Cannot think of anything else.

juicejuice commented 1 year ago

I can understand how frustrating this must be. It is very strange that the log message is not related to Redback. It could be a network error or something like that between HA and the Redback API? I can only think of two things to try: (1) trust me with your Redback credentials to test here, (2) run a test Python script I can send you. I would far prefer #2 but you would probably need to run that on the same machine that is running HA. There might be a way to get HA to run the Python script directly, I haven't checked into that as I'm on holidays at the moment.

juicejuice commented 1 year ago

@dereksatgmxcom also, just in case you haven't seen my video about the setup https://www.youtube.com/watch?v=KCcosSW-Vnw. Does that help at all?

dereksatgmxcom commented 1 year ago

The video above is what started me on this adventure. I was going to ask if you had a test platform that you could try my credentials. I don't think they give access to the controls of my inverter. I have started reading up on running python scripts in HA, I am probably thrill seeker enough to try. I have had practice a re-installing HA already if it goes wrong.

dereksatgmxcom commented 1 year ago

I copied the Curl command for Alive from Swagger UI and pasted it into the HA ssh terminal. Received the response "OK" The thing is that I cannot find another example on Swagger UI (random sample) that does not result in some form of error response in Swagger.

dereksatgmxcom commented 1 year ago

Using "Alive" is not a good test, on the swagger site it returns "OK" without going through the authorisation process. I think I will email to Redback next week to confirm the api details.

juicejuice commented 1 year ago

@dereksatgmxcom try the following:

  1. Navigate to the Redback Swagger API site: https://api.redbacktech.com/docs/index.html
  2. Click green "Authorize" button, on the right-hand side
  3. In the pop-up, enter your client_id and client_secret (copy-paste from Redback email), then click "Authorize" a. If you get a red "Auth Error" or "Bad Request" then your credentials are wrong b. If successful, the green "Authorize" button in the pop-up should now say "Logout" instead, and client_id and client_secret become uneditable asterisks
  4. If successful, close "Close" on the pop-up and you can now try a proper API method
  5. Try the /Api/v2/EnergyData example, click the method open, click "Try it Out", then click blue "Execute" button below - this should produce a response in the box below
dereksatgmxcom commented 1 year ago

Enter my client_id and client_secret all the open padlocks close. For step 5. above the response is { "Error": "Attempted to perform an unauthorized operation." } I have tried this several times over the last weeks, clicking "Try it Out" for each GET example, always getting some variation of the above message. I have valid codes but they appear to have no authority. I will contact Redback after Easter.

dereksatgmxcom commented 1 year ago

So I emailed Redback last week to confirm the details I am using are correct. After phoning them today I received a another link to the api credentials. This gave me exactly the same credentials as the previous link they sent. Tried them at api.redbacktech.com and can get authorisation the same as before.

Graphic 1

This gives me locked padlocks but the same "Error": "Attempted to perform an unauthorized operation." message for /Api/v2/EnergyData.

Graphic 2

I have also updated to the latest HA Redback integration but still get the Invalid Credentials message.

juicejuice commented 1 year ago

Wow that is very odd! I have also found Redback support a bit hit and miss. To be honest, if the API example doesn't work then you're not going to have any luck with the HA integration. It uses the exact same API calls. I would bet money that Redback has not configured your account correctly. Googling that error message shows example like this (https://sharepoint.stackexchange.com/questions/305189/sharepoint-rest-api-api-web-currentuser-attempted-to-perform-an-unauthorized-op) where the error goes away once the account is configured correctly. You are not doing anything wrong and only Redback can fix this issue. You will need to keep on to the support team to fix this, ask them to check that the access permissions are set correctly for your API account.

dereksatgmxcom commented 1 year ago

I have replied to today's email from Redback with the same details I include above, I will see what happens.

I my phone call with tech support this morning I tried suggesting that they had failed to link my api to my inverter but the tech guy was not interested, telling me to wait for an email response to my previous ticket.

It did sound like he was working from home and the kids were giving him a hard time.