I am trying to save some reports (in csv) on google drive from google app engine. It works fine if I hit the URL directly (after it bounced to google for authorization and click thru the screen to allow the app to access google drive)
But what if I initialize the request from cronjob in google app engine. Is there a way to let the app by passes the click thru? (or have a forever valid token?)
Note: same google account for the app and drive
For your app to access a user's data using a cron job, you will first need to get a set of OAuth 2.0 access and refresh token from the user: this should have been already implemented by you through the "click thru".
Once you get those credentials, you just have to store them in the datastore and retrieve them in the cron job in order to perform your tasks.
Retrieve and Use OAuth 2.0 Credentials shows an example of how to build an authorization flow and how to store/retrieve OAuth 2.0 credentials. Your cron job will simply need to retrieve those stored credentials and use them as usual.
Related
I have just developed a new Android app for my company.
On the home page of the app we would like to display a number of our companies latest Facebook posts.
When send the request to the API i am receiving the error
"message": "(#200) Access to this data is temporarily disabled for non-active apps or apps that have not recently accessed this data due to changes we are making to the Facebook Platform. https://developers.facebook.com/status/issues/205942813488872/"
I have looked into this extensively and understand it is due to Facebook upgrading their APIs due to the recent data breach.
Within the app i have successfully implemented the Facebook Login API and can retrieve a new access token for the user.
I have generated all the necessary hash keys for the android app and have set it all up correctly on the facebook developer console.
I can achieve the functionality i require by getting the Access token from the Facebook developers Graph API Explorer however, this is not a good implementation as it is linked to my Facebook account and also only lasts for an hour.
The Facebook API states that public pages can be accessible using any user access token.
Is there currently anyway at all to use a user access token generated from the user login to retrieve a Facebook page data.
the only data i wish to retrieve is; the message, the time created and the image.
Is this possible with the current state of the Graph API or is it just a waiting game to see what Facebook will do next in the coming weeks?
Thanks.
I am using Google Drive API's using JAVA for getting drive files, i want to create a background job which will fetch the google drive files
without any user interaction (eg asking for user to explicity Authorize).
In the example given below by google, after running this java program we need to explicitly hit URL in browser & click on Authorize
for full execution of the program.
https://developers.google.com/drive/v3/web/quickstart/java
Using the Service Account I am able to fetch the google drive contents without any kind of user action (eg click on allow to authorize).
I want to acheive the same flow for individual user accounts, I have the list of emailid and passowords for google accounts.
Other than service accounts, is there any method so that i connect to the authorization url in background using HTTPPost request and
fetch the file list.
I don't think there's another way of doing this aside from Service Accounts which you are currently using. You can try to use the Google Playground but this is for testing purposes only and not for production.
Previously, in order to use Google Drive service, we are using the following simple username and password login in Desktop application with Google Documents List API
DocsService client = new DocsService(getCloudApplicationName());
client.setUserCredentials(username, password);
As in Google announcement, https://developers.google.com/google-apps/documents-list/, Version 3 of the Google Documents List API has been officially deprecated as of September 14, 2012. It will continue to work as per our deprecation policy, but we encourage you to move to the Google Drive API.
So, in our desktop Swing application, we need to rewrite the code to gain authentication to Google Drive service.
By referring to code example run at console https://developers.google.com/drive/quickstart-java#step_3_set_up_the_sample
Please open the following URL in your browser then type the authorization code:
https://accounts.google.com/o/oauth2/auth?access_type=online&client_id=888888888888.apps.googleusercontent.com&redirect_uri=urn:ietf:wg:oauth:2.0:oob&response_type=code&scope=https://www.googleapis.com/auth/drive
User need to open up the browser manually.
Key in his username and password.
He will then obtain a special string from browser, where he needs to copy and paste to the console.
I think I can pretty much simply the process, by using a web view component Integrating JavaFX 2.0 WebView into a Swing Java SE 6 Application, so that the above task will be automated.
However, the webview's component previous history session will be destroyed as I close my desktop Swing application. User need to key in his password and username every-time he launch the desktop app.
From official Google Drive app for Windows, I realize it does have the capability to remember the last authentication of the user. User just need to key in his username and password once. He can then use the Google Drive service again and again, even after restarting the computer.
May I know how I can achieve the similar behavior?
You need to permanently store web view's cookies and set them again once you launch the web view again.
I have a requirement where I want images to be stored/retrieved from a single Google Account (this account has picasa storage). This should be done even if the user who is logged in to my web app, is different from the single google account (which has picasa storage).
(I plan to store all images used by this web app in Picasa Storage).
I couldnt find any example/reference for this particular scenario-- the docs talk about regular oauth authentication, where the user who is using the web app, gives permission to the web app to access his picasa images... What I want is, the single stored user (who has the images stored in his picasa account) is authenticated by the web app, even if a different user is logged in to the web app... Now the application can display images from the authenticated user's picasa albums...Can this be implemented? And ideally by using the google data apis client library for Java?
The answer is provided in Google Documentation of the API- at http://code.google.com/apis/picasaweb/docs/2.0/developers_guide_java.html#ClientLogin
The user id and password has to be stored in the application, and irrespective of whichever user is using the application, auth into Picasa will be done for the stored user only.
This is referred to as Single-user "installed" client authentication in the docs...
I want to send emails from my app engine application using one of my Google Apps accounts. According to the GAE python docs:
The From: address can be the email address of a registered administrator (developer) of the application, the current user if signed in with Google Accounts, or any valid email receiving address for the app (that is, an address of the form string#appid.appspotmail.com).
So I created a user account on my Google Apps domain, no-reply#mydomain.com, to use for outbound email notifications. However, when I try to add the user as an administrator of the app, it fails with this error:
Unauthorized
You are not authorized to access this application
Is it possible to configure app engine to send emails using a Google Accounts email address?
You must restrict your App Engine app to a Google Apps domain upon initial registration of your App Engine application ID. Unfortunately, this setting can only be set during the initial registration of your app ID.
What you'll need to do is register another application ID, set your authentication option for Google Apps domain, and upload your existing app to the newly registered ID.
Simply going through the "Domain Setup" process in your Dashboard is not enough; you'll only be able to add the app as a service and "host" it using your domain name. To restrict the authorization to your domain only, you'll need to do the first step in the initial registration.
I had also problems adding administrators. In the end, I used a regular gmail account as the sender. Which only works if sending as *#googlemail.com. *.gmail.com fails.