/**
  @file tokenauth.sas
  @brief Get initial tokens using an auth code - DEPRECATED

  <h4> SAS Macros </h4>
  @li mpeinit.sas
  @li mv_tokenrefresh.sas

  @author 4GL Apps Ltd
  @copyright 4GL Apps Ltd.  This code may only be used within Data Controller
    and may not be re-distributed or re-sold without the express permission of
    4GL Apps Ltd.
**/

%webout(FETCH)

data _null_;
  set work.fromjs;
  call symputx('viyasettings',viyasettings);
  call symputx('client_id',client_id);
  call symputx('refresh_token',refresh_token);
run;

data authme;
  /* get client info from special location */
  infile "&viyasettings" dsd;
  input client_secret:$100.;
  client_id="&client_id";
  refresh_token="&refresh_token";
run;
/* get tokens */
%mv_tokenrefresh(inds=authme, outds=fromSAS(keep=refresh_token access_token))

/* send back to frontend */
%webout(OPEN)
%webout(OBJ,fromSAS)
%webout(CLOSE)
