Skip to content
This repository was archived by the owner on Sep 2, 2025. It is now read-only.

Commit 54a5cba

Browse files
committed
fix gist_create to look for possible scopes problem in auth fix #70
1 parent ef044b0 commit 54a5cba

File tree

7 files changed

+23
-40
lines changed

7 files changed

+23
-40
lines changed

R/gist_create.R

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,6 @@
2424
#' numbers
2525
#' '})
2626
#'
27-
#' # or include results if you want, and change the filename in this case
28-
#' gist_create(code={'
29-
#' x <- letters
30-
#' numbers <- runif(8)
31-
#' numbers
32-
#'
33-
#' [1] 0.3229318 0.5933054 0.7778408 0.3898947 0.1309717 0.7501378 0.3206379 0.3379005
34-
#' '}, filename="my_cool_code.R")
35-
#'
3627
#' # Knit an .Rmd file before posting as a gist
3728
#' file <- system.file("examples", "stuff.Rmd", package = "gistr")
3829
#' gist_create(file, description='a new cool gist', knit=TRUE)
@@ -54,11 +45,10 @@
5445
#' '}, knit=TRUE)
5546
#'
5647
#' library('httr')
57-
#' base <- "http://pelias.mapzen.com/search"
58-
#' res <- httr::GET(base, query = list(input = 'coffee shop', lat = 45.5,
59-
#' lon = -122.6))
48+
#' url <- "https://github.com/ropensci/geojsonio/blob/master/inst/examples/zillow_or.geojson"
49+
#' res <- httr::GET(url)
6050
#' json <- httr::content(res, as = "text")
61-
#' gist_create(code = json, filename = "pelias_test.geojson")
51+
#' gist_create(code = json, filename = "zillow_or.geojson")
6252
#'
6353
#' # Knit and include source file, so both files are in the gist
6454
#' file <- system.file("examples", "stuff.Rmd", package = "gistr")
@@ -77,8 +67,7 @@
7767
#' cat(readLines(file), sep = "\n") # peek at file
7868
#' gist_create(file, knit=TRUE)
7969
#' ## if not, GitHub doesn't allow upload of binary files via the HTTP API
80-
#' ## (which gistr uses) but check back later as I'm working on an option to
81-
#' ## get binary files uploaded, but will involve having to use git
70+
#' ## (which gistr uses) - so see gist_create_git(), which uses git
8271
#' file <- system.file("examples", "plots.Rmd", package = "gistr")
8372
#' gist_create(file, knit=TRUE, imgur_inject = TRUE)
8473
#' ## works with ggplot2 as well

R/zzz.R

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,12 @@ stopstatus <- function(x) {
106106
encoding = "UTF-8"), FALSE)
107107
errs <- sapply(res$errors, function(z) paste(names(z), z, sep = ": ",
108108
collapse = "\n"))
109-
stop(res$message, "\n", errs, call. = FALSE)
109+
# check for possible oauth scope problems
110+
scopes_problem <- ""
111+
if (is.null(x$`x-oauth-scopes`)) {
112+
scopes_problem <- " GitHub response headers suggest no or insufficient scopes\n To create gists you need the `gist` OAuth scope on your token."
113+
}
114+
stop(res$message, "\n", errs, "\n", scopes_problem, call. = FALSE)
110115
}
111116
}
112117

inst/examples/example1.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ And I shall summarize them.
77
summary(x)
88

99
## Min. 1st Qu. Median Mean 3rd Qu. Max.
10-
## -3.73500 -0.70820 -0.03440 -0.05312 0.66780 3.22000
10+
## -2.83791 -0.65021 0.06139 0.01810 0.67508 3.02495

inst/examples/plots.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
plot(mpg ~ cyl, data=mtcars)
88
```
99

10-
![plot of chunk unnamed-chunk-2](http://i.imgur.com/Xs5LxrB.png)
10+
![plot of chunk unnamed-chunk-2](https://i.imgur.com/UVoPCi3.png)
1111

1212
## Bar plot
1313

@@ -16,7 +16,7 @@ plot(mpg ~ cyl, data=mtcars)
1616
barplot(VADeaths)
1717
```
1818

19-
![plot of chunk unnamed-chunk-3](http://i.imgur.com/r2AzPmZ.png)
19+
![plot of chunk unnamed-chunk-3](https://i.imgur.com/13Re4qX.png)
2020

2121
## Histogram
2222

@@ -25,4 +25,4 @@ barplot(VADeaths)
2525
hist(iris$Petal.Length)
2626
```
2727

28-
![plot of chunk unnamed-chunk-4](http://i.imgur.com/IyZzKVb.png)
28+
![plot of chunk unnamed-chunk-4](https://i.imgur.com/EItnHcZ.png)

inst/examples/plots_imgur.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
plot(mpg ~ cyl, data=mtcars)
88
```
99

10-
![plot of chunk unnamed-chunk-2](http://i.imgur.com/fs0ReVy.png)
10+
![plot of chunk unnamed-chunk-2](https://i.imgur.com/giiuYcd.png)
1111

1212
## Bar plot
1313

@@ -16,7 +16,7 @@ plot(mpg ~ cyl, data=mtcars)
1616
barplot(VADeaths)
1717
```
1818

19-
![plot of chunk unnamed-chunk-3](http://i.imgur.com/2hTWmZW.png)
19+
![plot of chunk unnamed-chunk-3](https://i.imgur.com/jL7cJJb.png)
2020

2121
## Histogram
2222

@@ -25,4 +25,4 @@ barplot(VADeaths)
2525
hist(iris$Petal.Length)
2626
```
2727

28-
![plot of chunk unnamed-chunk-4](http://i.imgur.com/VYADPOf.png)
28+
![plot of chunk unnamed-chunk-4](https://i.imgur.com/OcymFMa.png)

inst/examples/rmarkdown_eg.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ ggplot(mtcars, aes(cyl, hp)) +
2020
theme_grey(base_size = 18)
2121
```
2222

23-
![plot of chunk unnamed-chunk-3](http://i.imgur.com/SeIaFEQ.png)
23+
![plot of chunk unnamed-chunk-3](https://i.imgur.com/qhAguQK.png)
2424

2525
## Bar plot
2626

@@ -31,4 +31,4 @@ ggplot(iris, aes(Species, Sepal.Length)) +
3131
theme_grey(base_size = 18)
3232
```
3333

34-
![plot of chunk unnamed-chunk-4](http://i.imgur.com/Di7yeGJ.png)
34+
![plot of chunk unnamed-chunk-4](https://i.imgur.com/byOPWhp.png)

man/gist_create.Rd

Lines changed: 4 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)