Use Fusion Table like a database with PHP and how to dismiss the prompt page when using oauth

微笑、不失礼 提交于 2019-12-24 03:05:56

问题


I am developing a PHP application which would use Google Fusion Tables only as a database in the background. The application includes a simple login section for basic security. I downloaded the google-api-php-client and successfully built up a connection to my Fusion Table using oAuth. Thats fine. However, I want to get rid off the prompt screen, that says that my registered application want to access Fusion Tables and asks me to allow or disallow. Since the app would use a Fusion Table being hosted on my account, I think there is no need to ask this question from the user. Can you advise me any workaround to this? I plan to keep it as simple as possible, and would be really happy if there would be a way to get the authentication done without prompting the user with any additional screens.

Thanks so much for your help!

https://developers.google.com/fusiontables/docs/articles/oauthfusiontables


回答1:


The OAuth prompt you describe is needed if you want to access a users Fusion Table, so you basically ask the user for access to his account so you can use it to create tables and stores/retrieve data.

But in your case you want to give your users access to your Fusion Tables that you created with your account. Google introduced for this use case so called Service Accounts.

All you have to do is:

  1. create a Service Account (you can do this in the Google API console -> "Access API")
  2. download the private key
  3. give the Service Account access to you table (click on the "Share" button in the Fusion Tables web UI)
  4. use the Service Account in your code to access Fusion Tables

Some time ago I created a simple UPDATE example using a Service Account.




回答2:


Also, if you really do not need the sharing, visualization and publishing features of Fusion Tables, and just need a cloud database, consider using Google Cloud SQL which is designed for that usage.

https://developers.google.com/cloud-sql/docs/introduction



来源:https://stackoverflow.com/questions/12949701/use-fusion-table-like-a-database-with-php-and-how-to-dismiss-the-prompt-page-whe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!