MRCIEU / ieugwasr

R interface to the IEU GWAS database API
https://mrcieu.github.io/ieugwasr/
Other
73 stars 23 forks source link

user() giving me an error after the authentication #65

Closed Bhashitha2014 closed 5 months ago

Bhashitha2014 commented 5 months ago
error_message

As mentioned in the documentation, I was able to generate the token from https://api.opengwas.io/profile/ and updated it in .Renviron. In addition, I was able to confirm the token with ieugwasr::get_opengwas_jwt(). However, user() function is giving an error. When I tried to fetch the data from the server, I am getting an error ..

error_2
Bhashitha2014 commented 5 months ago
error with user()
jekriske-lilly commented 5 months ago

This error is caused by the if block at https://github.com/MRCIEU/ieugwasr/blob/master/R/query.R#L91-L96 not being checked for an error first like the if blocks above it within in the while loop.

It also doesn't appear that the JWT stuff is fully implemented yet so it's not going to work anyway without changing this around https://github.com/MRCIEU/ieugwasr/blob/master/R/query.R#L26-L27

The third issue is that we block the new API URL, but we'll deal with that internally.

Once @explodecomputer is finished with the 1.0 release I'm sure this will all work fine, it looks like he's still in progress.

Bhashitha2014 commented 5 months ago

Is there anything that I can run from my end to fix this issue?

error_ieugwasr
explodecomputer commented 5 months ago

In the latest commit the user function should be working now, and I've made the change that @jekriske-lilly spotted (thanks for that). See if it fixes otherwise let me know what code you used to generate the error and I can have a look again.

explodecomputer commented 5 months ago

A quick note also to not share your token with others as it's essentially a password. You can reset the one posted above on the profile page.

Bhashitha2014 commented 5 months ago

When I just followed the steps mentioned under the authentication step as mentioned below;

Authentication

  1. Login to https://api.opengwas.io/profile
  2. Generate a new token
  3. Add OPENGWAS_JWT=<token> to your .Renviron file. This file could be either in your home directory or in the working directory of your R session. You can check the location of your .Renviron file by running Sys.getenv("R_ENVIRON_USER") in R.
  4. Restart your R session
  5. To check that your token is being recognised, run ieugwasr::get_opengwas_jwt(). If it returns a long random string then you are authenticated.
  6. To check that your token is working, run user(). It will make a request to the API for your user information using your token. It should return a list with your user information. If it returns an error, then your token is not working.

However, I am still getting the error as mentioned.

JasonQiu commented 5 months ago

Please confirm you are using the latest version (0.2.2-9003 at time of writing) and also note https://github.com/MRCIEU/ieugwasr/issues/65#issuecomment-2058909831

Bhashitha2014 commented 5 months ago

Please confirm you are using the latest version (0.2.2-9003 at time of writing) and also note #65 (comment)

0.2.2.9002

JasonQiu commented 5 months ago

Detach and remove (you current) ieugwasr, then remotes::install_github("mrcieu/ieugwasr")

Bhashitha2014 commented 5 months ago

Detach and remove (you current) ieugwasr, then remotes::install_github("mrcieu/ieugwasr")

Thanks a lot! It is now resolved.

remlapmot commented 5 months ago

Yes - always detach packages before updating them - or simpler still just restart (close and reopen) your R session.

And remember you can install a prebuilt binary version for several different operating systems and architectures from https://mrcieu.r-universe.dev/builds

For Windows and Mac users

install.packages("ieugwasr", repos = c("https://mrcieu.r-universe.dev", "https://cran.r-project.org"))

For Ubuntu Jammy Jellyfish users

# Installation code for Ubuntu Jammy Jellyfish users running R in the Terminal
options(HTTPUserAgent = sprintf(
  "R/%s R (%s)",
  getRversion(),
  paste(getRversion(),
        R.version["platform"],
        R.version["arch"],
        R.version["os"])
))

install.packages(
  'ieugwasr',
  repos = c(
    'https://mrcieu.r-universe.dev/bin/linux/jammy/4.3/',
    'https://packagemanager.posit.co/cran/__linux__/jammy/latest',
    'https://cloud.r-project.org'
  )
)