Open LiNk-NY opened 4 years ago
gc_auth(new_user = TRUE, cache =TRUE ),
if you pull the help log you will see that this is a third set-able option in the .Rprofile as well.
Thanks @Karnner2 for resolving the error. The cache=TRUE
would be helpful to have in the README.md
.
@benjcunningham I am still having authentication issues given that the documentation isn't very clear.
Does the client_key
correspond to the API key that we generate here?
Does the client_secret
correspond to the 'Client secret' under OAuth 2.0 Client IDs
?
Where does Client ID
under OAuth 2.0 Client IDs
fit into all of this?
These are the options:
This is my setup:
Your help is appreciated. Thanks!
@LiNk-NY , I know you asked @benjcunningham but the following works for me.
gc_auth(new_user=TRUE, key= ' your API key', secret = 'API secret/passcode', token = NULL, cache=TRUE)
With respect to where the key generation occurs, yes, those should work. It appears that the code is just dated (possibly) and the Oath2.0 terminology has replaced the prior terminology that @benjcunningham used. It still works. You only need the client ID if you are going to be editing someone else's calendar through the API, but if I recall you need your app approved by Google in order to do this. The new_user=TRUE
parameter will activate a browser which will give your computer a token for your session. You only need to do it the one time so long as the session ID is good.
No, thanks for helping Jonathan! @Karnner2
For some reason, calling gc_auth
without .Rprofile
settings works.
I used the key = <Client ID>
and secret = <Client secret>
from the Google Developer's Console
otherwise it would give me an error if I tried to use a generated key = <API key>
:
Authorization Error
Error 401: invalid_client
The OAuth client was not found.
After authenticating successfully(?), I ran gc_ls()
and got an error:
gc_ls()
Error: C stack usage 7971948 is too close to the limit
In addition: Warning messages:
1: `tbl_df()` is deprecated as of dplyr 1.0.0.
Please use `tibble::as_tibble()` instead.
This warning is displayed once every 8 hours.
Call `lifecycle::last_warnings()` to see where this warning was generated.
2: `funs_()` is deprecated as of dplyr 0.7.0.
Please use `funs()` instead.
See vignette('programming') for more help
This warning is displayed once every 8 hours.
Call `lifecycle::last_warnings()` to see where this warning was generated.
3: `funs()` is deprecated as of dplyr 0.8.0.
Please use a list of either functions or lambdas:
# Simple named list:
list(mean = mean, median = median)
# Auto named with `tibble::lst()`:
tibble::lst(mean, median)
# Using lambdas
list(~ mean(., trim = .2), ~ median(., na.rm = TRUE))
This warning is displayed once every 8 hours.
Call `lifecycle::last_warnings()` to see where this warning was generated.
4: `mutate_each_()` is deprecated as of dplyr 0.7.0.
Please use `across()` instead.
This warning is displayed once every 8 hours.
Call `lifecycle::last_warnings()` to see where this warning was generated.
It seems like there is a recursive call somewhere. I haven't looked into it. :disappointed:
@LiNk-NY, you can ignore the errors for now. Although they are depreciated it should not actually matter for the time being. Be-careful with what you are getting though, the function gc_ls()
returns a list not a df or vector. So within the list result you need to call the specific list element (i.e. 'summary'), try the following:
result<-gc_ls(pattern="")
result$summary
Also yes, there is no actual need to set up a .Rprofile
when accessing an API, you can always call directly through the client function. The .Rprofile
is just a 'hide my information' method so that you don't accidentally commit to github your API Key and Secret (or other userID and password set). Having actually done this on accident, I can attest to its usefulness in that way. 😁
After you have identified the calendar you want to manipulate using gc_ls()
(for example, I use this API to automatically post meals to my calendar by merging with Spoonacular API so I will provide some 'methods' in that framework,) do
Eating<-gc_summary("Eating Schedule")
where Eating Schedule
is the name of my calendar found from gc_ls; you post a new event with the following type of call:
gc_event_new(Eating, start=list("T11:00:00Z"), end=list("T12:00:00Z), summary="Event Title", description="Event Details")
the Event Title
is what would show up in your main event on your gCalendar, this is usually a recipe name for me in this framework so let's say 'Thai Shrimp Soup'. The 'Event Details' contains all the information that is additional such as location, and notes about what the meeting is for etc. I was intuitive that since google runs HTML5 you can push HTML markup through this as a string and google will render it appropriately.
So you can pass headers (<h2>
) and breaks (<br>
) plus list mark-ups, etc. in HTML and google handles it flawlessly. Here is an example of what this looks like. I simply make a loop with strings, times and dates using the bizdays
, lubridate
, and bsts
libraries.
@Karnner2
I see, it seems like the show
/print
method is broken :grimacing:
Thanks for all the help! I am able to see my events now.
Cool example! It almost looks like a breakfast recipe for shakshuka :wink: I wonder if you can render an RMD to HTML for the calendar. It might be overkill but at least I've got things working now! Thanks again!
All the best, Marcel
I have a problem with auth as well, although it seems different. Whenever I would like to connect to the calendar through the package and the API, it fails.
The Authentication seems successful, but then if I want to list out the available calendars (or load a calendar by ID, or anything else), I get an error. My code is the following:
gc_auth( new_user = T, key = CLIENT_ID, secret = CLIENT_SECRET, verbose = T, token = NULL, cache = T )
After this, I get the browser popping up, I allow the app to connect, and returning to R I see the message: Authentication complete.
So after this I run gc_ls()
, but get the following error: Error in function_list[[k]](value) : Bad Request (HTTP 400).
I've tried many formats for gc_ls, also tried with different Google application (OAuth clients), and always get the same result.
Does anyone have a suggestion for this?
Thanks, Berta
Hi Berta! @BertaBojte
It seems like you were able to authenticate okay.
You then have to do something like:
res <- gc_ls(pattern = "")
res$summary
Best, Marcel
I'm on the same page as Berta.
res <- gc_ls(pattern = "") res$summary
Gives me
`res <- gc_ls(pattern = "")
Error in httr::GET(url, gc_token()) %>% httr::stop_for_status() : Forbidden (HTTP 403).
res$summary Error: object 'res' not found
`
Hi @abjeroen
Make sure the authentication is complete after you get the browser pop-up.
Best, Marcel
@abjeroen
It looks like build_url
appends the key
parameter in the URL. This is not needed.
I have a fork at https://github.com/LiNk-NY/googlecalendar that should fix this.
I am with the same Errror as @BertaBojte
After "Authentication complete."
I try to use gc_ls(pattern = "") and give me the Error: Error in httr::GET(url, gc_token()) %>% httr::stop_for_status() : Bad Request (HTTP 400).
How can I fix this?
Thanks Oscar
Try gc_ls(pattern=“”) or, if google’s backend is using regex you may need to go that route, gc_ls(“.”)
Right now you are asking it to find “string null” and that might be the bad request.
On Thu, Dec 29, 2022 at 4:23 AM oscarepaezm @.***> wrote:
I am with the same Errror as @BertaBojte https://github.com/BertaBojte After "Authentication complete."
I try to use gc_ls(pattern = "") and give me the Error: Error in httr::GET(url, gc_token()) %>% httr::stop_for_status() : Bad Request (HTTP 400).
How can I fix this?
Thanks Oscar
— Reply to this email directly, view it on GitHub https://github.com/benjcunningham/googlecalendar/issues/20#issuecomment-1367182433, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALHTXJHBMQQMIS2NUC4TVF3WPVJ77ANCNFSM4KRUW3BQ . You are receiving this because you were mentioned.Message ID: @.***>
I also see Marcel has forked the correction. While I haven’t examined either the original main branch source or Marcel’s fork, based on the description—the gc_ls uses build_url and that build_url at one point required the API key to be in it for the API’s server to accept the request.
Google may have updated their end-point and so you will need to update as well. So try using Marcel’s fork and or what I referred to and see if that doesn’t fix your problem. Let us know if not.
On Thu, Dec 29, 2022 at 9:26 AM Jonathan Fluharty @.***> wrote:
Try gc_ls(pattern=“”) or, if google’s backend is using regex you may need to go that route, gc_ls(“.”)
Right now you are asking it to find “string null” and that might be the bad request.
On Thu, Dec 29, 2022 at 4:23 AM oscarepaezm @.***> wrote:
I am with the same Errror as @BertaBojte https://github.com/BertaBojte After "Authentication complete."
I try to use gc_ls(pattern = "") and give me the Error: Error in httr::GET(url, gc_token()) %>% httr::stop_for_status() : Bad Request (HTTP 400).
How can I fix this?
Thanks Oscar
— Reply to this email directly, view it on GitHub https://github.com/benjcunningham/googlecalendar/issues/20#issuecomment-1367182433, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALHTXJHBMQQMIS2NUC4TVF3WPVJ77ANCNFSM4KRUW3BQ . You are receiving this because you were mentioned.Message ID: @.***>
Try gc_ls(pattern=“”) or, if google’s backend is using regex you may need to go that route, gc_ls(“.”) Right now you are asking it to find “string null” and that might be the bad request. … On Thu, Dec 29, 2022 at 4:23 AM oscarepaezm @.> wrote: I am with the same Errror as @BertaBojte https://github.com/BertaBojte After "Authentication complete." I try to use gc_ls(pattern = "") and give me the Error: Error in httr::GET(url, gc_token()) %>% httr::stop_for_status() : Bad Request (HTTP 400). How can I fix this? Thanks Oscar — Reply to this email directly, view it on GitHub <#20 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALHTXJHBMQQMIS2NUC4TVF3WPVJ77ANCNFSM4KRUW3BQ . You are receiving this because you were mentioned.Message ID: @.>
Now with gc_ls(pattern="*")
the the function is working !!!
Thanks so much!
@benjcunningham
I am not sure if I'm providing the right credentials and the instructions are not very clear. I am getting an error when I added my
googlecalendar.client_key
andgooglecalendar.client_secret
in my~/.Rprofile
file. I must be missing something... Did you meanclient_id
andclient_secret
as shown here? https://weblizar.com/blog/get-google-calendar-client-id-and-client-secret-key/ If so, I've tried that and it doesn't work. I've also tried using myAPI Key 1
as thegooglecalendar.client_key
value and the client secret but to no success.It would be good to have a template / description of what these keys look like or a step-by-step on how to obtain them as above.
Thanks, Marcel
Created on 2020-02-07 by the reprex package (v0.3.0)