mdhom / node-red-contrib-google-oauth-calendar

2 stars 2 forks source link

Step 2: Get authentication code #5

Open Balbao opened 3 years ago

Balbao commented 3 years ago

Hello, in step 2, when I click on "open google authentication" nothing happens. No browser window opens. What should I do?

ryancasler commented 3 years ago

Same here. I also had to import my client ID and Secret by hand, It would not take them out of the pop-up box.

drewp commented 3 years ago

WFM. Hopefully your pasted json starts like {"installed":{"client_id"?

If you didn't make the right type of oauth credentials ("TV"), your json might start with something else like {"web": which won't work.

wivaku commented 3 years ago

Does not work for me either. Import works (redirectUri shows as urn:ietf:wg:oauth:2.0:oob? also tried the other one http://localhost), but nothing happens when clicking 'open Google authentication'). Reason: browser console shows there's a 404 when trying to open: https://MYSERVER/google-credentials/authUrl/MYSECRET/MYCLIENTID/urn:ietf:wg:oauth:2.0:oob Credentials type is TV client. Using Node Red inside Home Assistant.

JSON contents:

{
    "installed": {
        "client_id": "MYCLIENTID",
        "project_id": "MYPROJECT",
        "auth_uri": "https://accounts.google.com/o/oauth2/auth",
        "token_uri": "https://oauth2.googleapis.com/token",
        "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
        "client_secret": "MYSECRET",
        "redirect_uris": [
            "urn:ietf:wg:oauth:2.0:oob",
            "http://localhost"
        ]
    }
}
Toby-Mills commented 3 years ago

Wivaku I had the same problem, but solved it by performing the additional step of enabling the Calendar API by visiting: https://console.cloud.google.com/apis/api/calendar-json.googleapis.com/overview?project={project name}

wivaku commented 3 years ago

Calendar API was already enabled.
Home Assistant's Google Calendar Event component uses the same project without issues.

hunterdrayman commented 3 years ago

Thanks for the contributed nodes. Sadly, I have the same problem with the Open Google Authentication button not opening a window. Up to this point was fine (once I realised a TV-style credential was needed). The JSON looks good.

Is there a manual way of generating the code on the Google Console, please?

hunterdrayman commented 3 years ago

Thanks for the contributed nodes. Sadly, I have the same problem with the Open Google Authentication button not opening a window. Up to this point was fine (once I realised a TV-style credential was needed). The JSON looks good.

Is there a manual way of generating the code on the Google Console, please?

Solution: OK. Looks like it is a general access token problem related to timezone in Home Assistant 2021.06 as detailed here. I changed my tz to Etc/GMT, and things started working again.

timknowlden commented 3 years ago

Also does not work for me, maybe googles JSON output is different now?

{ "installed": { "client_id": "XXXXXX", "project_id": "XXXXXX", "auth_uri": "https://accounts.google.com/o/oauth2/auth", "token_uri": "https://oauth2.googleapis.com/token", "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", "client_secret": "XXXXXXX", "redirect_uris": ["urn:ietf:wg:oauth:2.0:oob", "http://localhost"] } }

blazejp83 commented 2 years ago

I have the same problem, the data is filled in the boxes after pasting, but Open Google authentication button does not open anything. When I check the console, there is the same 404 error as mentioned above. It seems that the button is supposed to open the address http://MYSERVER/google-credentials/authUrl/MYSECRET/MYCLIENTID/REDIRECTURI. So I've tried to open just the part http://MYSERVER/google-credentials (in my case that was http://192.168.1.138:8123/google-credentials ), and I'm getting 404 on this. Like this /google-credentials/ link does not work at all.

nimothy commented 2 years ago

@blazejp83 make sure you are accessing node-red directly rather than via homeassistant... It will be the same URL with the port: 1880 rather than 8123

MrDuco commented 2 years ago

Finally got it working!!! Sorry for the Swedish in the pictures hope it helps anyway.

  1. Create Oauth Credential in Google, they have to be of type "TV and Limited Input" image
  2. Download JSON (MUST start with {installed:) mine looked like this (it has to be on a single line I have "prettified" it to be more readable in this post) image
  3. Open Node red directly (as mentioned above). I had to use http://IPADDRESS:1880 (nothing else worked, like DNS name or https)
  4. Click on "Import JSON" paste the string to the input field this should fill the form looking like this image
  5. Click on the button "Get Authentication Code", this should now open a new browser window Select your account image Accept the access request eg. select the check boxes next to "See and download calendars that you have access to.." and "Show your activities...". Click on "Continue" image
  6. On the next page you will get the code. Copy this code. image
  7. Paste the code to Step 3 and click on the button "Enter Code" It should now expand and auto-fill a couple of more fields. image

You should now be able to click on "Add" in Node-red.

I had to click Done on the Node and then open it again to be able to see my Calendars image

Hope this works for the rest of u!

wivaku commented 2 years ago

@MrDuco thanks for the tutorial. With the local access the "Get Authentication Code" popup worked and I could indeed add the credentials. I also had to press Done on the node and reopen before I got the Calendar IDs. And it took me a while to realize I had to press the (+) button to add the selected calendar(s) before pressing Done.

One issue: when I switch back to Node-RED through Home Assistant, no Calendar IDs are available. Any ideas? Already defined nodes (with selected calendar IDs) still work, but I can't add new ones.

BTW. To get local access working: I was not sure what to use for basic auth, so I (temporarily) added to the config leave_front_door_open: true.

wivaku commented 2 years ago

In addition to the above: after a few days (using Node-RED in HA) I get invalid_grant similar to #6 and #7

Balbao commented 2 years ago

Ok

aterzaghi commented 2 years ago

Dears,

contrib is wonderful and it works perfectly for... ehm 1 week more or less.. then i got this message: API Error: invalid_grant ... I open the conif page and the token code disappeared. I reauthorize, I get from google the same token and I copy paste and it works perfectly .. for another week... any clue of what's going on? maybe I have to change some configuration in my google console? many thanks Andrea

GIGS1975 commented 1 year ago

@MrDuco Hello, may I ask, how was you able get that JSON with redirecURIs data inside? I am asking, becuase for Calendar-Node we have to create a TV type client, and as so, it doesn't have any redirect URI defined. So i am still not able to get this working. Tried to follow all these steps, byt the Open Google Authentication button still does nothing.

I am working with Node Red on my PC, and i have tried to use my Raspberry IP (manually put into redirect uri textbox)

This is the JSON that i got.

image

Unfortunatelly nothing happpens. Any help would be very apppreciated.

MrDuco commented 1 year ago

@MrDuco Hello, may I ask, how was you able get that JSON with redirecURIs data inside? I am asking, becuase for Calendar-Node we have to create a TV type client, and as so, it doesn't have any redirect URI defined. So i am still not able to get this working. Tried to follow all these steps, byt the Open Google Authentication button still does nothing.

I am working with Node Red on my PC, and i have tried to use my Raspberry IP (manually put into redirect uri textbox)

This is the JSON that i got.

image

Unfortunatelly nothing happpens. Any help would be very apppreciated.

It looks like you have a typo in your code. Remove the last } and try again

GIGS1975 commented 1 year ago

@MrDuco The typo is only in my example picture, generally it is not there.