rladies / meetupr

R interface to the meetup.com API
https://rladies.github.io/meetupr
MIT License
76 stars 25 forks source link

default OAuth key and secret shipped with meetupr not working? #79

Closed benubah closed 3 years ago

benubah commented 4 years ago

The documentation of meetupr suggests that, in a situation where the user has not provided a token, the packages uses a default token that is shipped with it here: https://github.com/rladies/meetupr/blob/master/R/zzz.R

However, I tried to run a simple call using the package without providing a token, but I am redirected to a browser to Log in, and that seems to be the only way to obtain a token. But once I have logged in once and the authentication is complete, I can now make as many API calls without needing to re-authenticate for several months due to the cache set to true.

To reproduce this scenario, I created a brand new project on RStudio and tried to run the following code:

groups <- find_groups(text = "r-ladies", api_key = "")

Result: I was redirected to a browser for authentication. Expected behaviour: I expected this to work automatically with the default token shipped with the package.

ledell commented 4 years ago

Hi @benubah, although this is weird that you have to log in, this is the expected behavior. Described in the README: https://github.com/rladies/meetupr#usage

Each time you use the package, you will be prompted to log in to your meetup.com account. The first time you run any of the meetupr functions in your session, R will open a browser window, prompting you to “Log In and Grant Access” (to the meetupr “application”).

When you read this, did you think that it applied only to when you are using your own token (vs built-in token)? Do you want to make a PR to the README to make it more clear? Thanks!

benubah commented 4 years ago

Thanks @ledell This appeared conflicting to me with the doc at https://github.com/rladies/meetupr/blob/master/R/meetup_auth.R. I was trying to review what is involved to setup an automated way of authentication using Travis CI without needing to "Log In and Grant Access" on a browser

I suspect that the default shipped token alone cannot solve this problem. Someone with a Meetup account needs to log in and get his token saved in R somehow and re-used on Travis.

I think I can consider adding a section in the README for Using Meetup tokens in a CI/CD context. Do you think this is relevant?

ledell commented 4 years ago

@benubah Yeah the browser logging in requirement is annoying to say the least... I think a section in the README for setting up CI/CD would be helpful.

I heard via @Athanasiamo that @jennybc had some ideas around how to allow non-interactive authentication (sorry to ping you here Jenny). I just wanted to check in to see if there was already some code or ideas around this to avoid any duplication of efforts.

ledell commented 4 years ago

@benubah A follow-up: I have confirmed with Jenny that no work has been started on this issue, so there's no concern about duplication of efforts. It sounds like there's desire to get this working w/o interactivity, so if you feel like working on it, Ben, feel free.

maelle commented 3 years ago

I'm on it @benubah, hoping to make a PR this week or next

maelle commented 3 years ago

@benubah your feedback on https://github.com/rladies/meetupr/pull/84 is welcome :-)

maelle commented 3 years ago

Also note that what's shipped in by default is an app, not a token.

beatrizmilz commented 3 years ago

We have a repo ( https://github.com/R-Ladies-Sao-Paulo/RLadies-Brasil ) that lists the events of R-Ladies in Brasil (since is all online now, it's easier to find the events in Portuguese in one place, and helps the organizers to avoid scheduling more than one event at the same date/time).

We used to add every event manually. But sometimes we forgot to updated it :/ So this week I found this package, and me and @jeanprado changed our repo code to get the events from the Meetup API (way easier and more complete, THANKS for this awesome package!)

I would like to set an GitHub Actions to update the data, but I'm no expert at GitHub Actions and I'm not able to figure it out how to do the authentication... Tried a bunch of stuff and only got errors on Actions...

From what I read, the work that @maelle is developing in PR #84 can help with that? Just want to be sure if that is it, or if I should be looking elsewhere.

Again, thanks so much for this awesome package :)

benubah commented 3 years ago

Hi @beatrizmilz I wonder if this helps to solve the problem for the meantime while you are looking for a permanent solution: Visit https://r-community.github.io/event-explorer/rcalendar.html and select "Latin America" at the top-left. This is still developing and not fully announced and I know I could add a filter by country in the future. But for now I guess this could be of help.

beatrizmilz commented 3 years ago

Hi @benubah ! Thank you so much for this suggestion. I was able to add an action to get the JSON of the events, filter for events in Brazil, and show in the README the recent events that are in the calendar! Thank you so much!

Now this data are from R Community Explorer Calendar: https://github.com/R-Ladies-Sao-Paulo/RLadies-Brasil#eventos-futuros-eventos-recentes 👍

maelle commented 3 years ago

@beatrizmilz yes if you have time please try using my branch and its docs, because it allows you to create a token that you can then use non interactively. You'd need to encrypt the token locally and then you only push the encrypted version and de-encrypt it using a CI secret. It might also make sense to discuss in the R-Ladies slack as @Athanasiamo will need a similar workflow for the website. Of course no need to if @benubah's solution works for you!

beatrizmilz commented 3 years ago

Hi @maelle ! Thank you for your suggestion. I can try! I think @benubah 's solution is something temporary, the best would be to have an action with meetupr. I tried to install your branch but got an error. Not sure if I tried to install in the wrong way. I also tried with the name of the branch (remotes::install_github("rladies/meetupr", "noninteractive")) and got the same error...

> remotes::install_github("rladies/meetupr#84")
Using github PAT from envvar GITHUB_PAT
Downloading GitHub repo rladies/meetupr@noninteractive
Erro: Failed to install 'meetupr' from GitHub:
  HTTP error 404.
  No commit found for the ref encoding

  Did you spell the repo owner (`ropensci`) and repo name (`vcr`) correctly?
  - If spelling is correct, check that you have the required permissions to access the repo.

EDIT:

I installed the package {vcr} and after that I was able to install your branch. I'll try to use it now! Thanks @maelle !

remotes::install_github("ropensci/vcr")

maelle commented 3 years ago

Thank you for test-driving it!

maelle commented 3 years ago

@benubah @beatrizmilz my PR has been merged. Can this issue be closed or are there remaining problems (I'd love to fix them)?

benubah commented 3 years ago

Great work @maelle ! I guess could be closed.