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

```
There’s nothing automagic that can do that. Two options that I can think of:

1. OLE the data to Excel
2. Create a second DataStore with the data set columns in the order you want, then copy the data across, one column at a time using dot notation, and SaveAs() the second DataStore.

In terms of runtime performance, I’d expect the second option will be faster, especially as the data set gets larger. 

Good luck.