GWAS数据库ieugwasr包最新配置API用户Token方法

1. 最新的 API 授权要求

https://api.opengwas.io/api/#authentication
image.png

官方说明:

To be deprecated soon - Token obtained from Google OAuth
The documentation provides a list of endpoints, the parameters they require, descriptions of the data that is returned, and an interactive way to try out each of the endpoints.
The database of GWAS summary data mostly contains public data, however there are some ‘private’ datasets, which can only be accessed by authorised users.
Authentication is managed using Google OAuth 2.0. In order to authenticate, you will need to generate a ‘token’ for each session in which private access is required.
The simplest way to obtain an authentication token is to use a browser to authenticate with your gmail account at this link.
The access token can also be obtained using the ieugwasr::get_access_token() function, more information about that here.


Now rolling out - JSON Web Token (JWT) issued by us

From Wednesday 1st May 2024, you need to prove your identity (authenticate) to use our service, even if you are querying a public dataset.
JSON Web Token (JWT) is used for authentication. The token is required for most endpoints. To obtain a token, sign in to the account page. You will be prompted to generate a token, which is valid for 14 days. To use your token, add it into your request header under the key Authorization with value Bearer your_token. Note that there is a whitespace between Bearer and your token.
The API documentation provides a list of endpoints, whether they are protected (require authentication), the parameters and responses, and an interactive way to try out. To try the protected endpoints, click the green ‘Authorize’ button in API docs and provide your token as instructed.


2. GWAS 数据库注册 API

  • 地址:https://api.opengwas.io/
  • 你可以使用不同的账户登录,额度不一样
  • 建议用微软账户或者 GitHub

image.png

  • 登录过后,创建一个 API token
  • 只显示一次,务必记得复制保存
  • 注意,每个token有效期为14天!!!

image.png


3. 设置 R(ieugwasr 包)

3.1 创建.Renviron文件

  • 可以在用户目录
  • 也可以创建在工作目录

3.1.1 在用户目录进行创建

  • 比如我的用户名是 bio,因此我的用户目录是 home/bio

image.png

3.1.2 修改.Renviron文件内容

  • 内容是:OPENGWAS_JWT=

image.png

3.2 重启 R session

  • 记得一定要重启 R session
  • 不知道怎么重启的建议直接重启电脑或者虚拟机

3.3 运行测试

 首先需要更新一下ieugwasr包
install.packages("ieugwasr")

# 或者你用github安装开发版:
# remotes::install_github("mrcieu/ieugwasr")

# 载入包
library(dplyr) #这个包提供管道符号支持
library(ieugwasr)

# 查看是否识别到token
ieugwasr::get_opengwas_jwt()
# 返回你的token,说明成功

# user(),查看token对应的用户信息
ieugwasr::user()

# api_status()
ieugwasr::api_status()


参考资料

  1. 最新 API 说明:https://api.opengwas.io/api/#authentication
  2. GWAS API 注册后台:https://api.opengwas.io/profile/
  3. GWAS API 官方文档:https://api.opengwas.io/api/docs
  4. ieugwaspy:https://mrcieu.github.io/ieugwaspy/index.html
  5. ieugwas 最新 API 配置:https://mrcieu.github.io/ieugwasr/articles/guide.html#authentication
  6. GWAS 数据库官网:https://gwas.mrcieu.ac.uk/
  • 24
    点赞
  • 34
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值