ql-io/ql.io — Issue #329: Dynamic params from udf with OAuth integration?
Author: x2on
Created: 2012-03-07 12:58:04+00:00
State: open

How is it possible to use udf functions in statement which are considered in the OAuth Part.
On my example below the request uses the udf parameter, but the OAuth uri doesn't know the parameter from the udf.

Any ideas?

im using the following select statement

```sql
select * from testtable where param('test')
```

the create table statement:

```sql
create table testtable
on select get from "http://rest.example.com/function/testValue={testValue}"
using patch "testPatch.js"
```

and patch:

```javascript
exports['udf'] = function() {
return {
'testValue' : function(a) {
if (a == 'test') {
return 'TESTVALUE'
}
else {
return 'OTHERVALUE'
}
}
};
};

var uriTemplate = require('ql.io-uri-template');

var OAuth= require('oauth').OAuth;

exports['patch headers'] = function(options) {
var h = options.headers;

var uri = uriTemplate.parse(options.statement.uri).format(options.params);

var oa = new OAuth("",
"",
"Key", "Secret",
"1.0", "http://localhost:3000/oauth/callback", "HMAC-SHA1", null);

var orderedParameters = oa._prepareParameters("",
"", "GET",
uri);

var authorization = oa._buildAuthorizationHeaders(orderedParameters);

h["Authorization"] = authorization;

return h;
};
```