 			for extra in (provider.oauth1.authorize.extra||[])
 				hard_params[extra] = req.params[extra] if req.params[extra]
 			for name, value of access_token.query
-				param = replace_param value, @_params, hard_params, parameters
+				param = @_replace_param value, @_params, hard_params, parameters
 				query[name] = param if param
 			headers = {}
 			headers["Accept"] = short_formats[access_token.format] || access_token.format if access_token.format
 			for name, value of access_token.headers
-				param = replace_param value, @_params, {}, parameters
+				param = @_replace_param value, @_params, {}, parameters
 				headers[name] = param if param
 			options =
-				url: replace_param access_token.url, @_params, hard_params, parameters
+				url: @_replace_param access_token.url, @_params, hard_params, parameters
 				method: access_token.method?.toUpperCase() || "POST"
 				oauth:
 					callback: query.oauth_callback

			options: opts.options,
			expire: 600
		dbstates.add data, (err, state) =>
			@dbstatesAddedCallback(err, state, provider, parameters, opts, callback)

	dbstatesAddedCallback: (err, state, provider, parameters, opts, callback) ->
		request_token = provider.oauth1.request_token
		query = {}
		if typeof opts.options?.request_token == 'object'
			query = opts.options.request_token
		for name, value of request_token.query
			param = replace_param value, @_params, state:state.id, callback:config.host_url+config.relbase, parameters
			query[name] = param if param
		headers = {}
		headers["Accept"] = short_formats[request_token.format] || request_token.format if request_token.format
		for name, value of request_token.headers
			param = replace_param value, @_params, {}, parameters
			headers[name] = param if param
		options =
			url: request_token.url


	_setParams: (parameters) ->
		@_params[k] = v for k,v of parameters

	_replace_param: (param, params, hard_params, keyset) ->
		param = param.replace /\{\{(.*?)\}\}/g, (match, val) ->
			return hard_params[val] || ""
		return param.replace /\{(.*?)\}/g, (match, val) ->
			return "" if ! params[val] || ! keyset[val]
			if Array.isArray(keyset[val])
				return keyset[val].join params[val].separator || ","
			return keyset[val]

	authorize: (provider, parameters, opts, callback) ->
		@_setParams(provider.parameters)
