Need to send https GET request using oauth

I am new to OAuth and trying to send an https GET request to get something. I used to use POSTMAN to verify this, and I was able to execute a GET request with OAUth 1.0 header authorization. Header resolution looks like

Authorization: OAuth oauth_consumer_key="xxxxxxxxxxxxxxxxxxx" ,oauth_signature_method="HMAC-SHA1" ,oauth_timestamp="1409861973" ,oauth_nonce="x1409861973681" ,oauth_version="1.0" ,oauth_signature="M+Dq62XboEd3+t6VDIcLy86zlQg=" 

The request looks like

 https://secure.api.abc.net/DataService/data/ServiceAccount?schema=1.0&form=json&byBillingAccountId={EQUALS,yyyyy} 

Please note that I can fulfill this penalty from POSTMAN.

Now I need to encode this in java and I can generate the oauth signature fine, but I am wondering how do I configure the authorization header after that in the https request ???

Please advise as I am new to oauth and want to study.

0
source share
1 answer

I think if you do this in Java, you will need to use Apache HttpClient or something similar to make this request to the server and set the OAuth header for the request.
Sample code using Apache HttpClient below.

 HttpClient client = HttpClientBuilder.create().build(); HttpGet request = new HttpGet(url); // add request header request.addHeader("OAuth", oauthHeaderString); HttpResponse response = client.execute(request); 
0
source

Source: https://habr.com/ru/post/1201927/


All Articles