简体   繁体   English

在 Shinyapps.io 中运行 gmailr

[英]Running gmailr in shinyapps.io

I just deployed a shiny app in shinyapps.io.我刚刚在 Shinyapps.io 中部署了一个闪亮的应用程序。

It worked fine locally but when I deployed it, the gmailr authentication popup did not appear.它在本地运行良好,但是当我部署它时,没有出现 gmailr 身份验证弹出窗口。

I checked the logs in shinyapps.io, and it is working in the background but not in the front end.我检查了 Shinyapps.io 中的日志,它在后台运行,但不在前端运行。

For example, when I run the function:例如,当我运行该函数时:

options(httr_oauth_cache=T)
gmailr::clear_token()
gmailr::gmail_auth()

The logs in shinyapps.io shows this which is expected, but no popup: Shinyapps.io 中的日志显示这是预期的,但没有弹出窗口:

在此处输入图片说明

The expected output should be a popup asking me to choose which gmail account to authenticate.预期的输出应该是一个弹出窗口,要求我选择要进行身份验证的 Gmail 帐户。

Anyone have any experience using the gmailr package in shiny?任何人都有在闪亮中使用 gmailr 包的经验?

EDIT:编辑:

There is a file called .httr-oauth in my directory, but not rsconnect.我的目录中有一个名为 .httr-oauth 的文件,但没有 rsconnect。

在此处输入图片说明

Should I copy this file to my rsconnect folder?我应该将此文件复制到我的 rsconnect 文件夹吗?

This is the directory to my app in shinyapps.io through rconnect:这是通过 rconnect 在 Shinyapps.io 中我的应用程序的目录:

在此处输入图片说明

Figure it out if anyone wants to reference this in the future:弄清楚将来是否有人想参考这个:

Steps to host Gmailr in Shiny Apps:在 Shiny Apps 中托管 Gmailr 的步骤:

1) set your options locally to be: 1)在本地将您的选项设置为:

options(httr_oob_default = TRUE, httr_oauth_cache=TRUE)

gmailr::clear_token()

Run your Shiny App.运行您的 Shiny 应用程序。

2) A popup will appear for you to select your gmail account. 2) 将出现一个弹出窗口供您选择您的 Gmail 帐户。

3) Instead of automatically connecting you, an authentication code will appear. 3) 会出现验证码,而不是自动连接您。 You need to copy and paste that authentication code in your r console where it prompts you to paste it.您需要将该身份验证代码复制并粘贴到 r 控制台中,它会提示您粘贴它。

4) In your work directory, you will now have a httr oauth file saved. 4) 在您的工作目录中,您现在将保存一个 httr oauth 文件。 That is what grants you access to your gmail account.这就是授予您访问 Gmail 帐户的权限。

5) Exit the shiny app. 5) 退出闪亮的应用程序。 Remove the options from the script and save:从脚本中删除选项并保存:

options(httr_oob_default = TRUE, httr_oauth_cache=TRUE)

gmailr::clear_token()

6) Upload the shiny app with the httr oauth file in your directoy to shinyapps.io 6) 将带有 httr oauth 文件的闪亮应用上传到 Shinyapps.io

App should call your gmail account now without asking you to authenticate!应用程序应该立即调用您的 Gmail 帐户,而无需您进行身份验证!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM