consume REST oauth service from ABAP – get access token in order to call main webservice – part 1

I have heard many things about REST, oauth, JSON and all these things. Finally i have to meet these terms this week. There was a third party tool which is provding a REST service and i have to consume it with ABAP. Interestingly i learnt that there is not any Enterprise Service infrastructure in order to call REST services. Therefore i had to use HTTP service objects within ABAP program library. cl_http_client is the main class for REST services. Calling a REST service is consist of two parts. In this post i will focust on the first part. It is getting access token which is required to successfully make main webservice and this is the second poart of REST service.
There are a few different authentication method to get access token. I have used password as grant type. Below i am sharing my custom functiom module code which i have used to acquire an access token for my REST service. Z_GET_ACCESS_TOKEN function returns the access token acquired from the provider service and gives an exception if the service does not return an 200 (successfull http call).


You may also like