-
-
Notifications
You must be signed in to change notification settings - Fork 51
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
Issues with Cloud Print API #73
Comments
Hi Carl, that was easy enough to add, so its in now on GitHub version. Give it a go: library(googleAuthR)
options("googleAuthR.scopes.selected" = c("https://www.googleapis.com/auth/cloudprint"))
options(googleAuthR.verbose = 1)
options("googleAuthR.ok_content_types"= c(getOption("googleAuthR.ok_content_types"),
"text/plain"))
x <- gar_auth_service("path/to/my.json", scope = c("https://www.googleapis.com/auth/cloudprint"))
list_printers <- gar_api_generator("https://www.google.com/cloudprint/search",
checkTrailingSlash = FALSE)
list_printers() |
Thanks Mark. I was able to get a semi-functioning package started here. I am able to print small amounts of text using GET, but I have not been successful printing more substantial documents using POST. If you have any idea what I am doing wrong here I would greatly appreciate some guidance. Kind Regards, |
I think when using POST, you will need to send the data via a gcp_submit <- function(printerid,
title,
ticket = NULL,
content,
contentType = NULL,
tag = NULL,
http_header = c("GET", "POST")) {
http_header <- match.arg(http_header)
f <- googleAuthR::gar_api_generator(
"https://www.google.com/cloudprint/submit",
http_header = http_header,
data_parse_function = function(x) {
x$success
},
pars_args = list(
printerid = '',
title = '',
ticket = jsonlite::toJSON(list(
version = jsonlite::unbox("1.0"),
print = c()
), auto_unbox = FALSE),
content = '',
contentType = '',
tag = ''
),
customConfig = list(
# https://developers.google.com/cloud-print/docs/pythonCode#multipart-form-data
encode = "multipart"
),
checkTrailingSlash = FALSE
)
switch(http_header,
GET = f( etc... ),
POST = f(the_body = content) ## when POST, add the data as body
)
} |
Thanks I was able to get it to work. |
Hello,
Thank you for this wonderful package. I am having a small issue that I would like to share. After creating a service account and saving the JSON file, I get an error with this code:
Issue is appending
/
at the end of the URL gives a 404 error. Would it be possible to add a parameter togar_api_generator
for appending the/
which defaults to TRUE? This would allow for edge cases like mine to opt-out of the feature.I also find that
httr:::print.response
generates an error each time the result oflist_printers()
is printed, but it doesn't affect anything so far as I can tell.Kind Regards,
Carl
The text was updated successfully, but these errors were encountered: