Announcement

Collapse
No announcement yet.

Configuring Google Credentials

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

    Configuring Google Credentials

    Note: from version 4.0.2.0 it's not required to create your own client ID / secret.

    So the following procedure is not necessary, unless you want to create your own credentials.
    NOTE: New HS feature "Run as Service" prevents authorisation prompt.
    To configure Google credentials HS must run as normal process, not as service.
    Since Google use OAuth2 authentication protocol (which is not designed for console applications) this can be most difficult part depending on your OS and your setup.

    For initial credentials setup you have to use web browser on same computer where HS server is installed and logged in in your browser with your Google email.


    For Linux please see post Special first and this thread !

    Go to Google Calendar device configuration:
    Click image for larger version  Name:	config.jpg Views:	0 Size:	66.4 KB ID:	1484172
    Google changed the procedure, again. So I'll try to document the steps.

    It's a bit crazy, just follow the steps.
    1. Go to https://console.cloud.google.com/cloud-resource-manager

    2. Create New Project


    Click image for larger version  Name:	creds1.png Views:	0 Size:	45.0 KB ID:	1484173
    3.Name the project (any name)

    Click image for larger version  Name:	creds2.jpg Views:	0 Size:	49.5 KB ID:	1484174
    4. Select the created project

    Note: eaiser option for the following instructions is using project urls, I'll also list the urls - you need to append your project ID to the urls (i.e. project=gcal-3-320002)

    Click image for larger version  Name:	creds1a.jpg Views:	0 Size:	7.1 KB ID:	1484175
    5. Select "APIs and services" and Dashboard. Select "ENABLE APIS AND SERVICES"

    URL: https://console.cloud.google.com/api...=gcal-3-320002
    Click image for larger version  Name:	creds4a.png Views:	0 Size:	49.8 KB ID:	1484176 Click image for larger version  Name:	creds4.png Views:	0 Size:	27.8 KB ID:	1484177
    6. Select "Google Calendar API" and Click ENABLE

    URL: https://console.cloud.google.com/api...=gcal-3-320002
    Click image for larger version  Name:	creds5.jpg Views:	0 Size:	28.1 KB ID:	1484178 Click image for larger version  Name:	creds6.jpg Views:	0 Size:	30.0 KB ID:	1484179
    7. Select "Create Credentials".

    Select Google Calendar API from the list, select "User Data", then "Next":


    URL: https://console.cloud.google.com/api...=gcal-3-320002
    Click image for larger version  Name:	creds7.jpg Views:	0 Size:	55.3 KB ID:	1484183 Click image for larger version  Name:	creds8.jpg Views:	0 Size:	80.6 KB ID:	1484184
    8. CONFIGURE CONSENT SCREEN -

    Enter App Name, Email (twice), Click "SAVE AND CONTINUE"


    Click image for larger version  Name:	creds9a.jpg Views:	0 Size:	71.1 KB ID:	1484185
    9. On SCOPES screen Click "ADD OR REMOVE SCOPES"

    Select "calendar.readonly" and "calendar.events", click "UPDATE",
    Click "SAVE AND CONTINUE"

    Click image for larger version  Name:	creds9.png Views:	0 Size:	71.0 KB ID:	1484186
    10. "OAuth Client ID"

    Application type: Desktop App, Click "Create" and "Done"

    Click image for larger version  Name:	creds10.jpg Views:	0 Size:	85.8 KB ID:	1484188
    11. "OAuth consent screen"

    URL: https://console.cloud.google.com/api...=gcal-3-320002

    Test users => ADD USERS

    Add your gmail address again

    Click image for larger version  Name:	creds13.png Views:	0 Size:	60.5 KB ID:	1484199
    12. Select 'pencil' to see the client ID and Secret

    URL: https://console.cloud.google.com/api...=gcal-3-320002

    Click image for larger version  Name:	creds11.jpg Views:	0 Size:	77.0 KB ID:	1484198
    13. Copy"Client ID" and "Client Secret" to your Google Calendar Credentials configuration and click "Save"

    Google should pop-up OAuth authorisation window, follow the prompts. When finished - the plugin should get the list of you calendarts and create HS devices - 5 event devices per calendar.

    Click image for larger version  Name:	config.jpg Views:	0 Size:	66.4 KB ID:	1484200

    #2
    Using authenticator.exe for headless HS install

    If the HS is installed on headless (no GUI) Linux computer - the last reserve is to use authenticator.exe on another computer which does have GUI (better Windows) to obtain authorization token from Google. The app is included in the plugin install in "HS root"/bin/AKGoogleCalendar - copy the whole folder to Windows computer.

    Note 1: Before using authenticator.exe you still have to obtain (and save/Submit on the config page) ClientID and ClientSecret from Google - follow instructions post #2 Configuring Google Credentials.

    Note 2: On Linux even if you execute a command from the directory where it's located - you still need to prepend path, i.e:
    Code:
    ./authenticator.exe
    Note 3: And make sure on Linux it has the executable bit set, i.e:
    Code:
    sudo chmod a+x authenticator.exe

    Now execute:
    Code:
    authenticator.exe ClientID ClientSecret
    It should request "User login & consent" and receive "Authorisation code" and on success print list of your calendars:

    Code:
    *********************************************
    Credential file saved to: D:\My\Temp\Release\token.json
    
    D:\My\Temp\Release\token.json\Google.Apis.Auth.OAuth2.Respon ses.TokenResponse-user
    
    *********************************************
    pp08kp35e77ap05mmm94a00gmk@group.calendar.google.com
    S-Heat #f691b2 i04d1nir7395dmril3dvpstijg@group.calendar.google.com
    S-Gates #16a765 jgcuopiksi78f231qq5t23b2pg@group.calendar.google.com
    omeseer #fbe983 95dfa41185hao6gmvpss2nelro@group.calendar.google.com HS-TV #ffad46
    All you need to do now - in Google Calendar Credentials configuration click "Upload Credentials" and point to the file received above. This should copy the file to the plugin bin folder on HS machine.

    Alternatively you can copy created token.json folder manually to: "HS root"/Bin/AKGoogleCalendar/token.json"

    Then restart plugin.

    Comment


      #3
      Windows 10
      HS4 Pro
      Google Calendar API

      Following all instructions, and including adding the .json file to "C:\Program Files (x86)\HomeSeer HS4\Bin\AKGoogleCalendar\token.json" folder ,restarting plug-in and getting the awaiting authorization, Ive even opened HS4 pro in Chrome and opened the appropriate gmail account to no avail..
      Please advise

      Comment


        #4
        Originally posted by austinbl View Post
        Windows 10
        HS4 Pro
        Google Calendar API

        Following all instructions, and including adding the .json file to "C:\Program Files (x86)\HomeSeer HS4\Bin\AKGoogleCalendar\token.json" folder ,restarting plug-in and getting the awaiting authorization, Ive even opened HS4 pro in Chrome and opened the appropriate gmail account to no avail..
        Please advise
        Can you please describe what exactly "no avail" means?
        And what .json file did you add to "C:\Program Files (x86)\HomeSeer HS4\Bin\AKGoogleCalendar\token.json"?
        And lease provide output from Tools => Help
        And anything in the logs?
        I need info, thank you.

        Comment


          #5
          Can you please describe what exactly "no avail" means?
          Nothing works, all attempts proves useless.


          And what .json file did you add to "C:\Program Files (x86)\HomeSeer HS4\Bin\AKGoogleCalendar\token.json"?
          I added the one with the client id and secret, It has the same info i copied /pasted after the Google API >creating the credentials then plugging into the Google API plugin

          And lease provide output from Tools => Help

          Code:
          Date/time=1/8/2022 1:10:55 AM Central Standard Time
          Version=HS4 Pro Edition 4.2.7.0 (Windows)
          License=Registered
          Confguration File=C:\Program Files (x86)\HomeSeer HS4\Data\HomeSeerData.json
          In Virtual Machine=No MFG: dell inc.
          Antivirus=Windows Defender
          OS=Microsoft Windows 10 Pro - Work Station
          OS Version=10.0.19044
          Uptime=7 Days 0 Hours 59 Minutes 35 Seconds
          Lan IP=192.168.1.171 (Automation_PC)
          Device Count=26
          Event Count=1
          Processor:=Intel64 Family 6 Model 94 Stepping 3 at 2.97 GHz
          Modules/Threads=129 Modules, 59 Threads
          Available Threads=1023
          System Load=208 Processes, 9% Load
          Free/Total Memory=558.80 MBytes / 3.89 GBytes (14% free)
          Free/Total Virtual Memory=1.26 GBytes / 7.75 GBytes (16% free)
          HomeSeer Memory Used=52 Mbytes
          Plugin Memory Used=7 EXE Plug-Ins using 95 Mbytes
          Plugins Installed=AK GoogleCalendar 4.0.0.20,AK Traccar 4.0.0.44,Ecobee 4.0.15.0,IFTTT 3.0.1.4,LIFX 4.0.7.0,MyZWaveParameters 3.20.0.9,NetCam Plugin 1.0.0.5,Z-Wave 3.0.9.0,Z-Wave Parameters 4.0.35.0,Z-Wave UI 1.0.0.0
          And anything in the logs?

          Only this::


          1/8/2022 12:46:48 AM
          HomeSeer
          Device Control
          Device: GoogleCalendar Main Google Calendar to Poll (-102) by/from: CAPI Control Handler

          Comment


            #6
            Ver 4.0.0.22 (BETA) - Updated Google API to ver 1.55.0

            Please enable "Show Beta Plugins" in Plugins => Add to see the BETA version.

            I updated Google libraries, hope it helps.

            I see you have only 4GB RAM which may be a problem (if not now, then later) - I suggest to upgrade to 8GB.

            Comment


              #7
              It worked and I do plan to upgrade RAM to max 16GB ....

              Thank You

              Comment


                #8
                No problem

                Comment

                Working...
                X