gpt4 book ai didi

android - YouTube API v3 - 请求上传权限 - Android

转载 作者:太空狗 更新时间:2023-10-29 14:55:56 25 4
gpt4 key购买 nike

我目前正在根据代码 here 使用适用于 Android 的 YouTube API v3 将视频上传到 YouTube。 :

我想在延迟后执行上传,此时用户可能不再在应用程序中。我遇到的问题是,如果用户尚未授予我的应用上传到 YouTube 的权限,它将在上传时引发 UserRecoverableAuthIOException。然后文档建议我应该这样做:

startActivityForResult(uraioe.getIntent(), ACTION_REQUEST_AUTHORIZATION);

显示一个弹出窗口。在这一点上,如果用户已经离开应用程序,那么看到弹出窗口对他们来说是一种糟糕的体验,如果他们看到的话。我可以在上传文件之前预先授权我的应用具有上传权限吗?

最佳答案

听起来您想使用 access and refresh tokens .当您的用户正在使用该应用程序时,他们可以验证他们的帐户并允许您代表他们发出请求,从而创建访问 token 和刷新 token 。然后,如果他们下线,您只需要检查访问 token 是否已过期(通常在创建后一小时),如果已过期,请使用刷新 token ,您可以为他们发出授权请求。

请注意, token 可以 expire如果:

  • the user has revoked access.
  • The token has not been used for six months.
  • The user account has exceeded a certain number of token requests.

关于android - YouTube API v3 - 请求上传权限 - Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31450432/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com