适用于iOS的Google Drive API:具有应用程序所有帐户的OAuth2.0 [英] Google Drive API for iOS: OAuth2.0 with an application-owned account

查看:114
本文介绍了适用于iOS的Google Drive API:具有应用程序所有帐户的OAuth2.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个简单的iPhone应用程序。基本前提是应用程序会在应用程序上显示一些数据(我在线提供)。数据随时间而变化,所以应用程序必须从在线绘制数据并显示它。我没有重要的编程背景,所以我不想使用自己的服务器。

因此,我认为只要将数据放入Google帐户的某些文档中,然后通过Google Drive API以编程方式访问它们就会更加容易。然后,我可以更新我的云端硬盘帐户中的数据,并在应用程序中进行更新。这里的关键是我只能访问我拥有MYSELF的一个帐户。用户的账户没有被访问。因此,我们的目标是永远不必手动登录。它应该都发生在幕后,也就是说,它应该看起来像一个服务器,而不是一个谷歌文档。



考虑到这一点,显示没有意义Google帐户登录页面作为标准OAuth2.0教程显示给我的用户: https ://developers.google.com/drive/quickstart-ios#step_1_enable_the_drive_api



我应该可以通过我的用户名以某种方式硬编码来访问我自己的数据,密码等Google同意此处: https://developers.google.com/drive / service-accounts#use_regular_google_accounts_as_application-owned_accounts



上面的链接提到了我应该保存的刷新令牌。但是,我不知道如何构建和保存该令牌,甚至不知道如何找到它。

我已经阅读了iOS的基本教程和博士编辑教程,但他们都假设应用程序访问的是USER帐户而不是应用程序拥有的帐户。



我没有要求某人为我编写代码(虽然花絮很棒),但是如果您可以指引我逐步指导或相关的示例代码,这将帮助我开始这将是真棒。我甚至会回来发布我使用的代码!

编辑:由于我意识到Google Drive API不是我可以用来做什么的事情,我最终发现解析这是一个非常棒的工具,可以为我处理所有服务器后端,并且在基本级别上是免费的。



如果您想从服务帐户分发内容,也许应该编写一个服务器端进行身份验证,并以安全的方式传递客户端证书,以便他们代表服务帐户与API对话。或者,如果隐私不是非法的,请使用网络发布在没有授权和身份验证的情况下通用文档关注。

I'm creating a simple iPhone app. The basic premise is that the app will display some data (That I provide online) on the application. The data changes over time, so the app has to draw the data from online and display it. I don't have a significant programming background so I don't want to use my own server.

Thus, I thought it would be significantly easier to just put the data into some documents on a Google account and then access them programmatically via the Google Drive API. I could then update the data in my Drive account and it would get updated in the application. The key here is that I am ONLY accessing ONE account that I own MYSELF. The users' accounts are not being accessed. Therefore the goal is to never have to log in manually. It should all happen behind the scenes, aka, it should look like a server, not a google doc.

With this in mind, it doesn't make sense to show the Google Accounts sign-in page to my users as the standard OAuth2.0 tutorial shows here:https://developers.google.com/drive/quickstart-ios#step_1_enable_the_drive_api

I should be able to access my own data by somehow hardcoding in my username, password etc. Google agrees here: https://developers.google.com/drive/service-accounts#use_regular_google_accounts_as_application-owned_accounts

The above link mentions a "refresh token" that I'm supposed to save. However, I have no idea how to build and save that token, or even for that matter, where to find it.

I've gone through both the basic tutorial and the Dr. Edit Tutorial for iOS, but they both assume that the application is accessing USER accounts not application-owned accounts.

I'm not asking for someone to write the code for me (though tidbits are nice), but if you can point me to a step-by-step guide or related sample code that would help me get started that would be awesome. I'll even come back and post the code that I use!

EDIT: Since I realized that the Google Drive API wasn't something I could use for what I am trying to do, I eventually found Parse which is an awesome tool that handles all the server backend for me and is free at the basic level.

解决方案

Google APIs objective-C client library doesn't support service (application-owned) accounts, because they are supposed to be used by a server-side apps, instead of clients -- you shouldn't be distributing your private key as a part of an app.

If you would like to distribute content from a service account, maybe you should write a server leg to do the authentication and pass clients credentials in a secure way for them to talk to the API on the behalf of the service account. Or, use Web publishing to make documents universally accessible without authorization and authentication if privacy is not a concern.

这篇关于适用于iOS的Google Drive API:具有应用程序所有帐户的OAuth2.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆