Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
This tutorial was originally written in 2014 for my website. Although the Google screenshots may be slightly out of date and I wrote this using version 5.5.1 of Talend, you should still be able to make use of this. I have attached a copy of the job and a copy of the parameters file I used for this.
Google make use of the OAuth 2.0 protocol for authentication for (I think, but am happy to be corrected) all of their services. They do a pretty good job of describing the protocol. Once you have read through the documentation you should have a better idea of what you are doing, which should make this easier. The Google documentation is here.
The first thing that needs to be done is to create a Google Project. This is described below....
Create a Google Project
...Continued
15) "Get Access Token and Refresh Token" (tRESTClient)
This component is used to retrieve an access token and refresh token using the authorisation code retrieved from the component before.
To configure this component copy the configuration shown below. Ensure that the sections circled in red are set correctly. To add the "Query parameters" use the green plus symbol circled in red.
The values required can be seen above, but you can find them below so that you can copy and paste them.....
URL: ""<
Hi,
I followed the different steps, but I receive the following message :
https://accounts.google.com/o/oauth2/auth?scope=https://www.googleapis.com/auth/drive&state=12345678...
s://accounts.google.com/o/oauth2/auth?scope=https://www.googleapis.com/auth/drive
400|{
"error": "invalid_grant",
"error_description": "Malformed auth code."
}
Any idea on what I can be doing wrong??
I can see that your redirect_uri is incorrect. I used "http://localhost" (or "http%3A%2F%2Flocalhost" with the address url encoded).
https://accounts.google.com/o/oauth2/auth?scope=https://www.googleapis.com/auth/drive&state=123456789qwertyui&redirect_uri=https://developers.google.com/oauthplayground&response_type=code&client_id=XXXX-t701hme370kfagcvo1052id7e8jblo8b.apps.googleusercontent.com&approval_prompt=auto&include_granted_scopes=true&access_type=offline
Hi,
I've corrected this.
I now have the following url :
When I do this and put the correct access-token it works.
But unfortunateley after an hour this doesn't work anymore. I've also included the refresh token, but this doesn't seem to work.
I presume this is something that needs to be set up on the google account??
It has been a while since I wrote this job (I believe I did it in 2014), so the flow may have changed slightly. But the point of this job is that once the first token is received (access token), the refresh token is saved into a CSV file. The next time the job fails and requires a new access token, the refresh token will automatically be used to create one.
Using the refresh token to retrieve a new access token has a slightly different flow from the original flow to generate both a refresh token and access token. This may be what is tripping you up. However, if you have received a refresh token with your first access token, you should be able to use it to generate a new access token.
Have you tried downloading the job?
Not able to view/download the image
Hi,
Just tried your scenario it's great and well documented
I made some changes to retrieve the code
in the context file
replace : redirect_uri;http%3A%2F%2Flocalhost with : redirect_uri;urn:ietf:wg:oauth:2.0:oob
In the steps
13.
replace : redirect URL with : code
14.
comment/remove the substring part
15.
in query parameters
replace : http://localhost with : context.redirect_uri
Result :
In the browser you can directly copy-paste the code
It's less disturbing than the error page
Now I need to figure out how to retrieve data from Google with TOS and use it
Nice additions. This was written a long time ago and things have moved on a bit with Google OAuth 2.0 functionality. I'm glad this still works and that you have been able to improve upon it @powerchip