When you activate GAM, the REST WS you have start using OAuth as this document states and you need to provide the Client_Id, user, and password to the consumer.
The consumer needs to get an Access token with this credentials before trying to post to whe WS and all the calls to the REST web services should include this token on the header.
The following example is a complete sample code that shows how to GET the products list ("DPProduct" is a Data Provider exposed as REST web service), which is a secure web service (GAM is enabled in the KB). The Client Id is taken from the application defined automatically in GAM Backend.
Use HTTPClient data type to consume the REST web service.
//First get the access_token through an HTTP POST
&addstring ='client_id=be47d883307446b4b93fea47f9264f88&grant_type=password&scope=FullControl&username=test&password=test'
&httpclient.Host= &server
&httpclient.Port = &port
&httpclient.BaseUrl = &urlbase + '/oauth/'
&httpclient.AddHeader("Content-Type", "application/x-www-form-urlencoded")
&httpclient.AddString(&addstring)
&httpclient.Execute('POST','access_token')
&httpstatus = &httpclient.StatusCode
msg('Http status: ' + &httpstatus,status)
&result = &httpclient.ToString()
&AccessTokenSDT.FromJson(&result) // Load the AccessToken in a SDT which has this structure (*)
//call DPProduct web service
&httpclient.BaseUrl = &urlbase + '/rest/'
&httpclient.AddHeader("Content-Type", "application/json")
&httpclient.AddHeader('Authorization','OAuth ' + &AccessTokenSDT.access_token)
&httpclient.AddHeader("GENEXUS-AGENT","SmartDevice Application")
&httpclient.Execute('GET','DPProduct')
This is another example, this time using the GAMRepository.GetOauthAccessToken() method
//First get the access_token
&httpclient.Host= &server
&httpclient.Port = &port
&GAMOauthAdditionalParameters.ClientId = "f719771ad52a42919a221bc796d0d6b0"
&GAMOauthAdditionalParameters.ClientSecret = &ClientSecret
&GAMLoginAdditionalParameters.AuthenticationTypeName = !"local"
&AccessTokenSDT = GAMRepository.GetOauthAccessToken(!"admin", !"admin123",&GAMLoginAdditionalParameters,&GAMOauthAdditionalParameters,&GAMSession,&GAMErrors)
//call DPProduct web service
&httpclient.BaseUrl = &urlbase + '/rest/'
&httpclient.AddHeader("Content-Type", "application/json")
&httpclient.AddHeader('Authorization','OAuth ' + &AccessTokenSDT.access_token)
&httpclient.AddHeader("GENEXUS-AGENT","SmartDevice Application")
&httpclient.Execute('GET','DPProduct')
If you want your REST API to be consumed with no security as before activating GAM, you can set the property "Integrated Security Level" to NONE on the API.