raman325 / ha-zoom-automation

Custom Home Assistant component for Zoom. Tracks when you are connected to a Zoom call by default but may allow you to track more.
MIT License
60 stars 16 forks source link

Missing code or state parameter #52

Open barbergeek opened 2 years ago

barbergeek commented 2 years ago

So I am having the same issue as was previously reported. "Missing code or state parameter" when I try to install the application from the App Marketplace. Yes, I have carefully reviewed that thread but did not see an actual resolution to the issue, or anything that helped me to fix the problem. I have crosschecked the client id, secret, and verification token as well as the URL for the callback and whitelisting. My server is available externally @ https://[servername].duckdns.org. I am also using the NGINX Home Assistant SSL proxy along with the Duck DNS add-on. Any further guidance? Does someone have an example of a known good installation URL?

I'll also add that I'm running core 2021.12.10 on Home Assistant OS 7.2 with supervisor 2022.01.0

Version of the custom_component

0.82

Configuration

zoom:
  - client_id: [clientid]
    client_secret: [secret]
    verification_token: [token]
    name: google

Describe the bug

HA Server reports: Missing code or state parameter in http://[my valid server name]/auth/external/callback?code=[randomcode]

I also note that it reports http: rather than https:

johntdyer commented 2 years ago

So i fug up this ticket which had a similar issue but was resolved, not entirely clear how.... But based on the steps suggested in #22 I did try the following:

I checked my external URL in the config was correct tried my nabucasa one with remote on.

Added the correct URL in the event subscription and in the callback hook and this time I got the same error but oddly it was https this time in the URL it displayed 🤷

Untitled

raman325 commented 2 years ago

are you attempting to install the application from the Zoom website? If so, that will not work and will lead to this error. You instead have to add your client ID and Secret to HA and then set up the integration. As part of the integration setup, you will be sent to the zoom site to authorize and install the application in your account

barbergeek commented 2 years ago

Ah. Bad assumption on my part.

I may have made progress, but am getting a different error now when trying to start the integration. I changed the name in my configuration.yaml file to match the App Name I used in the App Marketplace. It now fails with this error: Logger: custom_components.zoom.common Source: helpers/update_coordinator.py:219 Integration: Zoom (documentation, issues) First occurred: 11:47:44 PM (1 occurrences) Last logged: 11:47:44 PM

Error fetching zoom data:

... continuing to diagnose and I'll check the closed issues list to see if there is anything relevant.
barbergeek commented 2 years ago

So I uninstalled and reinstalled the component and removed the "name:" from the config. It asked me for an account name when I reinstalled it and the log reports "Successfully authenticated". The next line is the "Error fetching zoom data:" mentioned in the previous comment.

I will note that I don't see this happening in the instructions: Authorize the app for the Scopes that were configured earlier.

barbergeek commented 2 years ago

My apologies. Pop-up blocker was preventing the zoom page to open, and I never noticed. I uninstalled and re-installed and it went much better. If I have other issues, I will open a new issue.

CHECK YOUR POPUP BLOCKER! /facepalm

raman325 commented 2 years ago

it happens! thanks for reporting back. @johntdyer were you able to resolve your issue? see my response above for my suspicion about the mistake you are making

johntdyer commented 2 years ago

@raman325 i am still getting an error... It appears to successfully recognize the plugins config but the entities are not available

image
2022-02-23 14:54:04 INFO (MainThread) [custom_components.zoom.config_flow] Successfully authenticated
2022-02-23 14:54:04 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up binary_sensor.zoom
2022-02-23 14:54:05 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new binary_sensor.zoom entity: binary_sensor.zoom_five9
2022-02-23 14:54:05 WARNING (MainThread) [custom_components.zoom.binary_sensor] Error retrieving initial zoom status, restoring state.
Traceback (most recent call last):
  File "/config/custom_components/zoom/binary_sensor.py", line 163, in async_added_to_hass
    self._profile = await self._api.async_get_contact_user_profile(self.id)
  File "/config/custom_components/zoom/api.py", line 35, in async_get_contact_user_profile
    resp = await self._oauth_session.async_request(
  File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 471, in async_request
    return await async_oauth2_request(
  File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 485, in async_oauth2_request
    return await session.request(
  File "/usr/local/lib/python3.9/site-packages/aiohttp/client.py", line 640, in _request
    resp.raise_for_status()
  File "/usr/local/lib/python3.9/site-packages/aiohttp/client_reqrep.py", line 1004, in raise_for_status
    raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 400, message='', url=URL('https://api.zoom.us/v2/chat/users/me/contacts/GB3qYG8[redacted]?query_presence_status=true')
2022-02-23 14:54:35 WARNING (MainThread) [custom_components.zoom.binary_sensor] Unable to reach Zoom, we may miss status updates until we can connect again
raman325 commented 2 years ago

are you in a company account or in a personal account? If you are in a company account, it's possible that your company is blocking the polling API. The intent of the logic that is throwing the log statement was to catch when the internet goes down, but that may be too aggressively making the sensor unavailable. But that would only be the case if you are monitoring a company account

johntdyer commented 2 years ago

@raman325 it is a corporate account. Do you have any documentation on where this limit is configured? I am pretty sure I can ask them to change it if i know were to tell them to look

raman325 commented 2 years ago

you would need access to event subscriptions for user activity as well as the chat_contact:read scope

raman325 commented 2 years ago

actually, looking at your error again, it seems that Zoom considers our request a bad request which indicates a problem on the client side. Can you try removing the zoom integration and setting it up again for the same account? Be sure to do all the setup within HA (except for the part where it opens up the zoom site for you to authenticate)

johntdyer commented 2 years ago

@raman325 so I have tried that several times with no luck

raman325 commented 2 years ago

got it well I doubt it is the permissions on the corporate side but maybe it's worth asking based on this comment https://github.com/raman325/ha-zoom-automation/issues/52#issuecomment-1057056129 ?

johntdyer commented 2 years ago

I am not seeing chat_contac:read

image

I have the following scopes

image

johntdyer commented 2 years ago

nevermind, i found the scope... I also noticed that I wasnt putting out account name int he first field.. It was prefilled w/ "Zoom" and I just assumed it was supposed to be that

raman325 commented 2 years ago

OK so is the issue resolved now, or are you still seeing the sensors as unavailable?

mhrynkewycz commented 2 years ago

Hi everyone, I am still getting the same error myself. Missing code or state parameter in https://xxxxxxx.duckdns.org/auth/external/callback?code=gOoR3T1rmG__MfcsQaMTGeu6UxM2IWxxx

Did anyone get to the bottom of this?

rmiles7721 commented 2 years ago

Getting the same missing code or state parameter as well.

raman325 commented 2 years ago

did you go through the config flow or did you try to install the app from the Zoom site?

mhrynkewycz commented 2 years ago

I’ve tried both options. Either way I get the same result.

On 5/04/2022, at 1:53 PM, Raman Gupta @.***> wrote:

 did you go through the config flow or did you try to install the app from the Zoom site?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.

raman325 commented 2 years ago

so you installed the zoom integration in Home Assistant, clicked the button in HA that opens the Zoom log in screen, logged in, and then the next thing you see is Missing code or state parameter? That typically only happens because the initial setup with Zoom didn't include this information from HA, but HA should add that to the URL when it takes you to the zoom login automatically

Normanras commented 2 years ago

Not sure if this is helpful, but I originally tried via the browser (dumb!) and got the error, which brought me to this issue. Despite that, I went into HA and checked everything, and the sensor works and is pulling information. The sensor changes to connected and disconnected appropriately.

I think the creation of the app through the browser does work, the caveat is to not click "Add" on the last screen. Just ignore that, go into HA and verify that it works. I hope that helps!

I know this is bit of an aside, but @raman325, do you know about any limits to the connection? If I quickly restart a meeting (within 10 seconds) of stopping a meeting, my sensor doesn't change from disconnected to connected again. If I wait a bit, then it picks up the change in status. Not sure if Zoom thinks the quick changes are some sort of spam bot. Screen Shot 2022-05-06 at 3 05 14 PM