Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello, I am new on Talend 🙂 Can I check if it is possible to use Talend to get the access key from google (https://www.googleapis.com/oauth2/v4/token) so that I am able to call this API?
Api URL : https://admin.googleapis.com/admin/directory/v1/users/
I have already managed to get the output on Postman but am not able to get the access token on Talend.
Kindly appreciate any help on this.
Thanks!
Thanks for the reply to this post.
Have referred to the link you have provided but did some minor changes.
Instead of tRestClient have managed to get the access_token with tRest instead.
HTTP Header: name = "content-type" and value = "application/x-www-form-urlencoded"
HTTP Body : "code=xxx&client_id=xxx&client_secret=xxx&refresh_token=<>&redirect_uri=https%3A%2F%2Fdevelopers.google.com%2Foauthplayground&grant_type=authorization_code"
Greatly appreciate your help.
OAuth2 can be tricky when you start working with it. I have put together a tutorial on this with Google quite a while ago. It may be slightly out of date, but the flow should work for you with a few a tweak. You can find this here...
I have also put together a YouTube demo of this with Twitter. It is very similar and should give you a good idea of how to achieve this. You can find this here. It also comes with a demo job.
Appreciate the prompt reply on this.
Having to look through both of the materials provided, can I kindly check on the purpose of having the "code" used in the TRestClient?
I have tried to call different APIs and it doesn't seem to require so many components. ( Usually either a tRESTClient or a tRest is sufficient)
Ah, OK. These examples are to show how you can fully implement solutions to deal with creating your OAuth 2 access token AND to regenerate them from refresh tokens when they expire. They were built to automate this generation and regeneration process. When I first started using OAuth 2.0 with Google applications, I found that it was somewhat painful to go through the steps manually when token expired. This is why these jobs are somewhat bigger than you might expect.
Ohh I see. But can I check why I am getting an Unauthorized message when I attempted to use the code to get the access and refresh token? Is there any specific permission that I would require to provide in the Google API Service?
Note that the appropriate scopes should already have been authorized as I managed to access the desired output on Postman. Not really sure what other permission I might have missed out on.
OK, this is coming from Google. So it suggests that what is being sent is incorrect. Can you show me how your tRestClient is configured (basic and advanced tab) and also show me how you are generating your token? Are you able to register a token? Has the token every worked? Or does it work and then start to fail? The tokens are time limited. We will get through this, but there are lots of little bits that can catch you out.
Oh, don't share your tokens as they are. Make sure you either change the tokens with a few extra characters or hide them 😉
Thanks for the reply to this post.
Have referred to the link you have provided but did some minor changes.
Instead of tRestClient have managed to get the access_token with tRest instead.
HTTP Header: name = "content-type" and value = "application/x-www-form-urlencoded"
HTTP Body : "code=xxx&client_id=xxx&client_secret=xxx&refresh_token=<>&redirect_uri=https%3A%2F%2Fdevelopers.google.com%2Foauthplayground&grant_type=authorization_code"
Greatly appreciate your help.
I'm glad you got it working. Thanks for sharing your way alternative way of doing this. There is seldom a single "right way" of doing something and sharing different ways helps everyone. This follow-up is much appreciated 👍
what goes in the redirect url?
thanks,
bob