Solved: I wasn’t providing the necessary headers. Jeremy
> On 10 Mar 2019, at 18:49, Jeremy Roussak via 4D_Tech <[email protected]> > wrote: > > Miyako, > > That was very helpful, thanks, and I’ve now completed that first step of the > “authentication journey”; I can get an authorization code which I can copy > and paste manually, which is fine: it will last for 18 months. > > The next step is using the authorization code to get an access token, and I’m > stumbling again. The documentation page > (https://developer.service.hmrc.gov.uk/api-documentation/docs/authorisation/user-restricted-endpoints#installed-applications) > says to do this: > > curl -X POST --data \ > 'client_secret=[YOUR-CLIENT-SECRET]&client_id=[YOUR-CLIENT-ID]&grant_type=authorization_code&redirect_uri=[YOUR-REDIRECT-URI]&code=[AUTHORIZATION-CODE]' > \ > https://test-api.service.hmrc.gov.uk/oauth/token > > > I’ve tried this: > > $url:="https://test-api.service.hmrc.gov.uk/oauth/token" > $body:="grant_type=authorization_code"+\ > "&client_id="+$clientID+\ > "&client_secret="+$clientSecret+\ > "&redirect_uri=urn:ietf:wg:oauth:2.0:oob"+\ > "&code="+$authCode > $err:=HTTP Request(HTTP POST method;$url;$body;$response) > > but all I get is an error saying “grant_type required”. I’ve tried fiddling > with the order of items in $body, but as expected it makes no difference. > > I assume I’m not translating the curl example properly into 4D. Help? > > Jeremy > >> On 10 Mar 2019, at 10:04, Keisuke Miyako via 4D_Tech <[email protected]> >> wrote: >> >> so the first thing to do is Google the docs with the keyword >> "urn:ietf:wg:oauth:2.0:oob" >> >> https://www.google.com/search?client=safari&rls=en&q=site:developer.service.hmrc.gov.uk+urn:ietf:wg:oauth:2.0:oob&ie=UTF-8&oe=UTF-8 >> > > ********************************************************************** > 4D Internet Users Group (4D iNUG) > Archive: http://lists.4d.com/archives.html > Options: https://lists.4d.com/mailman/options/4d_tech > Unsub: mailto:[email protected] > ********************************************************************** ********************************************************************** 4D Internet Users Group (4D iNUG) Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:[email protected] **********************************************************************

