[英]Google Drive service account for my android app
I want to use google drive to upload and download file directly from my Andriod app without any user interaction.I have followed google quick start page of drive api and it works correctly but thing is i want app to authenticate it self directly without asking user to select account it there any way that. 我想使用谷歌驱动器直接从我的Andriod应用中上传和下载文件,而无需任何用户交互。我已经遵循了驱动器api的谷歌快速入门页面,它可以正常工作,但是我想让应用直接对自己进行身份验证而不要求用户选择帐户有任何方式。 I can enter username and pass directly during code. 我可以输入用户名并直接在代码中传递。 there are options like service account 有诸如服务帐户之类的选项
when i google for this but no tutorial there are other tutorials with php and ruby but they are on browser i want it to be integrated with my app. 当我用谷歌搜索这个但没有教程时,有其他教程使用php和ruby,但是它们在浏览器中,我希望它与我的应用程序集成。 So as soon as i open my app it should fetch file from google drive without any user need 因此,一旦我打开我的应用程序,它便应从Google驱动器中获取文件,而无需任何用户
any help or link to tutorial for andriod app will be helpful 任何帮助或指向Andriod应用程序的教程的链接都将有所帮助
You can follow the service account sample in this repository . 您可以在此存储库中关注服务帐户示例。
Here's a snippet which shows how to build service account credential. 这是显示如何建立服务帐户凭据的代码段。
HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();
JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
...
GoogleCredential credential = GoogleCredential.fromStream(new FileInputStream("MyProject-1234.json"))
.createScoped(Collections.singleton(PlusScopes.PLUS_ME));
// Set up global Plus instance.
plus = new Plus.Builder(httpTransport, jsonFactory, credential)
.setApplicationName(APPLICATION_NAME).build();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.