Announcement

Collapse
No announcement yet.

Credentials procedure on linux headless

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

    Credentials procedure on linux headless

    Could you explain a step by step for this ?


    thanks

    #2
    As I said Google designed their OAuth2 authorization for web based apps, not console apps because when you request the authorization the app should provide a callback url where Google sends the response file. For Windows based console apps their API has built-in webserver which listens for this callback. On Linux this may not work. However I tested on my Raspberry installation and it did work, but you need to have a web browser and login with your Gmail account. Here's how Google describe the process:

    Some requests require an authentication step where the user logs in with their Google account. After logging in, the user is asked whether they are willing to grant the permissions that your application is requesting. This process is called user consent.

    If the user grants the permission, the Google Authorization Server sends your application an access token (or an authorization code that your application can use to obtain an access token)

    Click image for larger version

Name:	untitled.png
Views:	476
Size:	26.6 KB
ID:	1299456
    In the picture above - the problem is to do "User login & consent" and receive "Authorisation code" on headless machine.

    1. Basically you have to obtain OAuth2 response file using another computer (preferably Windows). I mean you need to do the authorisation procedure and Google API will save a file called Google.Apis.Auth.OAuth2.Responses.TokenResponse-user locally in folder token.json (yes, it's a folder, not file).

    2. Then on AKGoogleCalendar config page you can use "Upload Credentials" button to copy Google.Apis.Auth.OAuth2.Responses.TokenResponse-user file to the plugin bin folder. Alternatively you can copy the file manually to "HomeSeer HS3\Bin\AKGoogleCalendar\token.json" folder (may need to create "token.json" folder first).

    3. Once you have the response file in the correct location - you need to enter your Client ID and Client Secret in AKGoogleCalendar config page and click Submit. Since it's got the OAuth2 response already - it should just work.

    Main question how to do #1? I did it using another Windows HS installation. Otherwise I might need to create a simple app which you can run elsewhere and receive the Google.Apis.Auth.OAuth2.Responses.TokenResponse-user file.

    Comment


      #3
      You can use the HS myhs + your plugin as the callback URL. Then you can read the response directly via your plugin.

      Comment


        #4
        I will try this tomorrow or Friday . Thank alexbk66

        But what , said will simplify the procedure. I think phlocation does..exactly that!

        Comment


          #5
          Originally posted by Simplex Technology View Post
          You can use the HS myhs + your plugin as the callback URL. Then you can read the response directly via your plugin.
          That's how it normally works when you do it on the machine where the plugin itself is running and you have the myhs on the same machine. Then it's easy as Google Calendar API has already built in webserver which receives the callback.

          The problem is when your HS installation is headless, so you can't see the "User login & consent" which Google API pops-up and you can't click "Approve".

          Another option is to temporary run the plugin remotely on normal computer (preferably Windows) and then copy the received Google.Apis.Auth.OAuth2.Responses.TokenResponse-user file to HS machine. But then it's probably easier if I just create a separate little app to perform the authorization?

          What a pain...

          Comment


            #6
            Another option is to use https://developers.google.com/oauthplayground/ to obtain the response token. I will test and add to my documentation.

            Comment


              #7
              oauthplayground didn't work for me.

              So I created a little app authenticator.exe (attached) which you can run anywhere (after obtaining ClientID and ClientSecret):

              Note: I also recommend to use this app for testing your Mono version before you actually try to use the plugin. It makes it easier to troubleshoot Google Calendar API .NET dependencies.

              Code:
              authenticator.exe [I]ClientID ClientSecret[/I]
              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.Responses.TokenResponse-user
              
              *********************************************
              pp08kp35e77ap05mmm94a00gmk@group.calendar.google.com HS-Heat #f691b2
              i04d1nir7395dmril3dvpstijg@group.calendar.google.com HS-Gates #16a765
              jgcuopiksi78f231qq5t23b2pg@group.calendar.google.com Homeseer #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 the file manually to "HomeSeer HS3\Bin\AKGoogleCalendar\token.json" folder (may need to create "token.json" folder first)

              Then click "Submit" button to apply the credentials (you still need the ClientID and ClientSecret fields).

              Comment


                #8
                Thanks !! Will try it tomorow . Now, time to sleep (canada/Montreal).

                Comment


                  #9
                  ...

                  Comment

                  Working...
                  X