Lua变量即使设置为零也是零

时间:2015-01-08 09:26:57

标签: lua 3scale

我正在尝试修改3scale提供的lua文件。我一直收到以下错误:

runtime error: /etc/nginx/nginx.lua:361: attempt to concatenate field 'user_id' (a nil value)

导致此错误的代码块是:

local params = {}
local host = ngx.req.get_headers()["Host"]
local auth_strat = ""
local service = {}
if ngx.var.service_id == 'ID' then
  local parameters = get_auth_params("not_headers", string.split(ngx.var.request, " ")[1] )
  service = service_ID --
  ngx.var.secret_token = service.secret_token

  params.user_id = parameters.user_id
  -- Get access token from response
  params.access_token = parameters.access_token
  ngx.var.access_token = params.access_token .. ":" .. params.user_id
  get_credentials_access_token(params, service_ID)
  ngx.var.cached_key = "ID" .. ":" .. params.access_token
  auth_strat = "oauth"
  ngx.var.service_id = "ID"
  ngx.var.proxy_pass = "http://backend_api.mysite.com"
  ngx.var.usage = extract_usage_ID(ngx.var.request)
end

如果我在ngx.var.access_token = params.access_token .. ":" .. params.user_id之后放置get_credentials_access_token(params, service_ID),则不会发生错误。什么可能导致这种行为?

编辑:
原始文件可在https://github.com/3scale/nginx-oauth-templates/blob/master/oauth2/implicit-flow/token-generation/nginx.lua

找到

0 个答案:

没有答案