REST and Google Contacts API

REST and Google Contacts API

  
HI - I have tried to consume the  google contacts REST API. However I have the following questions before I try any more. I am trying to simply have a button on a web screen that adds a contact to a google contacts account..

1. Is REST fully supported in the Personal edition of OutSystems?
2. I have managed to send a POST request for obtaining an authorization code, but I get back in the response "200 OK" with the response body containing a lot of HTML/Javascript text from the google accounts sign in page! What is going on here? I would expect to see the authorization code somehow returned in the response, but it is not.

Sure this is obvious, but cannot figure out why :-( Any help gratefully received.

Andy.
Hi Andrew, 

Answering your questions:
1. Yes, REST Feature (consume in this particular case) is fully supported in the Personal environment.
2. I cannot answer this question directly because I don't know what you are trying to do and what you have accomplished so far.

I'm assuming that you are following this API and, if I'm right, you need to perform the OAuth2 authentication process. Have you managed to do that?
As far as I know, there is a 2 opt-in confirmation to get a token that may be sent in further requests to perform the real operations that you want to do like Get contacts or Add a new contact.

If you haven't perform the OAuth2 authentication, in this forge component (dropbox connector), you have an example on how to do it.

Hope it helped.

If I didn't answer your 2nd question, please elaborate a litle bit more your issue in order for us to help you.

Best regards
Many thanks for your response Nuno, I haven't even got an Authorization code yet. My request in the consume REST API dialog looks like this:
POST
https://accounts.google.com//o/oauth2/v2/auth?client_id=<myclientid>&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcontacts&response_type=code&access_type=online&redirect_uri=https%3A%2F%2Flogmycatch.outsystemscloud.com%2Flogmycatch%2Foauth2callback.aspx

When I click on "Test" in the dialog is when I get back HTTP:/1.1 200 OK and the Content-Type returned is text/html then a bunch of HTML. To be honest I don't know how to properly get the Authorization code at this stage so I can exchange for access token.

I shall check the Drop box example and see if that yields any clues.

Andy.
Hi Andrew

As you say you are on step 1. Look at the drop box connector to see if you dont have to reinvent the wheel

If reinventing the wheel you should read https://developers.google.com/identity/protocols/OAuth2UserAgent

Where it highlights as you are client side you dont get a json response but "Google returns the access token on the fragment of the response, and client side script extracts the access token from the response."

See the 
Handling the response section where it shows a potential method to parse the frgament (your text/html then a bunch of HTML) to extract the acces token.

Hopefully some one has already externalised "accounts.google.com/o/oauth2/v2/auth" which allows you to call an action with the url and spits out the token...

cheers
George

Yep it is all there and supported by Outsystems Labs.


AS George said, in the connector you have the common OAuth2 flow that it is used and is used by Google Contacts API.

That HTML Page is the 2 phase authentication and you should be redirected to the url that you supplied in configuration and in that URL you have to provide the remaining data in order to get a valid token.

Let us know if you succeeded.