Question: I am using [connect id](https://developers.onelogin.com/openid-connect/api/authorization-code-grant) to deal with rstudio login. After retreiving the [code](https://developers.onelogin.com/openid-connect/api/authorization-code) 
The API returns an error:{"error":"invalid\_grant","error\_description":"grant request is invalid"} and i have no idea why:

```
$ch=curl_init();
$header = array('Authorization: Basic '.base64_encode($client_id.':'.$secret), 'Content-Type: application/x-www-form-urlencoded');
$post = array('grant_type' => 'authorization_code',
'code' => $code,
'redirect_uri' => 'MY_URL');
$url = "https://eif-til.onelogin.com/oidc/token";
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
$result = curl_exec($ch);

```

All the variables entered seems fine, the authorisation code received seems fine and is passed as is. On Onelogin side everything seems configured as it should. My suspicion is on the PHP Curl code but I don't know what is missing/wrong

Answer: 
There are a few ways to do this. One way is via a second datastore which is populated via the ShareData method. This second datastore would use a datawindow object set up with the same columns as in the original datawindow but in the order you wish to have them in the export.
Code example for this:

```
int li

li = dw_primary.Sharedata(ds_excelexport)
IF li > 0 THEN
   dw_excelexport.Saveas("c:\temp\export.xls",Excel!,TRUE)
END IF

```
Here is the solution, 

```
    datastore lds_datastore
    lds_datastore = CREATE datastore
    lds_datastore.DataObject = "d_student_filter"
    lds_datastore.SetTransObject (SQLCA)
    lds_datastore.Retrieve()

    long ll

    ll = dw_filter.Sharedata(lds_datastore)

    IF ll > 0 THEN
       lds_datastore.Saveas("c:\Document\export.xls",Excel!,TRUE)
    END IF

```