New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need help setting up Google Calendar #83

Closed
ngocphamm opened this Issue May 31, 2018 · 11 comments

Comments

7 participants
@ngocphamm
Copy link

ngocphamm commented May 31, 2018

I think I've tried what I could... Please help

My config.yml. Yes, only with gcal module. That's all I need for now.

wtf:
  colors:
    border:
      Focusable: "darkslateblue"
      focused: "orange"
      normal: "gray"
  mods:
    gcal:
      colors:
          title: "red"
          description: "lightblue"
          past: "gray"
      conflictIcon: "🚨"
      currentIcon: "💥"
      withLocation: false
      displayResponseStatus: true
      email: "<myemail>"
      enabled: true
      eventCount: 5
      position:
        top: 0
        left: 0
        height: 1
        width: 1
      refreshInterval: 300
      secretFile: "~/.wtf/gcal/client_secret.json"

I have that client_secret.json by following this, and I confirm the credentials work fine with a REST Client (Paw).

However when I run wtf in my command line, I see a blank screen. Ctrl + C twice to get out of the program and I see something like this on the screen.

Go to the following link in your browser then type the authorization code:

https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=<my-client-id>&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&response_type=code&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcalendar.readonly&state=state-token

I could follow the link and generate the authentication token, but I have no way to "paste" it back to wtf.

Also, aren't the ENV variables NOT required anymore if there's the client_secret.json? They are basically the same stuff. https://wtfutil.com/posts/modules/gcal/

Thank you!

@d3sandoval

This comment has been minimized.

Copy link

d3sandoval commented May 31, 2018

I am having the same problem. I was able to get the oauth url while wtf was running by redirected the output (./wtf > out.txt) but when i sign in and copy/paste the code, wtf exits and says:

2018/05/31 10:36:57 Unable to retrieve token from web oauth2: cannot fetch token: 400 Bad Request
                                                                                                 Response: {
                                                                                                              "error" : "invalid_grant",
                                                                                                                                          "error_description" : "Malformed auth code."
                                        }
@cleverdevil

This comment has been minimized.

Copy link

cleverdevil commented May 31, 2018

Same here. From the code, it appears that it wants to store the cached token in ~/.credentials somewhere, but I don't know the format of the file.

@ngocphamm

This comment has been minimized.

Copy link

ngocphamm commented May 31, 2018

@cleverdevil more like it's going to save to ~/.credentials/calendar-go-quickstart.json once it get the auth token, but it seems to be failing at the step to fetch the token according to @d3sandoval.

@WesleydeSouza

This comment has been minimized.

Copy link

WesleydeSouza commented May 31, 2018

I was able to mix a bunch of instructions and code reading and got it to work.

Here's what I've done:

  1. cd ~/.wtf
  2. Followed all steps from "Step 1: Turn on the Google Calendar API"
  3. Moved the downloaded client_secret.json to ~/.wtf
  4. Created a file quickstart.go and paste the contents of the file from "Step 3: Set up the sample" there
  5. Ran go run quickstart.go
  6. mkdir -p ~/.credentials && mv ~/.wtf/token.json ~/.credentials/calendar-go-quickstart.json

This should get it to work.

I guess besides having these instructions somewhere, we need to update the gcal module to also read the token.json file from config.yml, it will make much more sense.

@d3sandoval

This comment has been minimized.

Copy link

d3sandoval commented May 31, 2018

@WesleydeSouza that worked! Very nice! To integrate the token handoff into the UX, we could use text input similar to the TODO module: https://github.com/senorprogrammer/wtf/blob/master/todo/widget.go#L195

@cleverdevil

This comment has been minimized.

Copy link

cleverdevil commented May 31, 2018

Yup, worked for me too :)

@ngocphamm

This comment has been minimized.

Copy link

ngocphamm commented Jun 1, 2018

Thanks @WesleydeSouza! It's working now, except that for some reason the dates of the events are not right for me. They are all Mon, Jan 1, 00:00. Anyone having the same issue?

@viluon

This comment has been minimized.

Copy link

viluon commented Jun 1, 2018

@ngocphamm Not all, but some of them are broken. Also, I don't see events imported from other calendars.

@senorprogrammer

This comment has been minimized.

Copy link
Collaborator

senorprogrammer commented Jun 3, 2018

Closing this issue. This PR adds a link into the GCal module documentation for the official Google documentation, and a link to @WesleydeSouza's comment above.

@h3

This comment has been minimized.

Copy link

h3 commented Jun 4, 2018

Step #2 of @WesleydeSouza's comment lead to a 404 ..

I believe this is the good link:

https://developers.google.com/calendar/quickstart/go#step_1_turn_on_the_api_name

@senorprogrammer

This comment has been minimized.

Copy link
Collaborator

senorprogrammer commented Jun 4, 2018

Thanks. I've edited the comment to point to that link now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment