alexsong93 commented on a change in pull request #198: Dao
URL: 
https://github.com/apache/incubator-openwhisk-apigateway/pull/198#discussion_r115308284
 
 

 ##########
 File path: scripts/lua/oauth/google.lua
 ##########
 @@ -23,46 +23,44 @@ local cjson = require "cjson"
 local http = require "resty.http"
 local request = require "lib/request"
 local utils = require "lib/utils"
-local httpc = http.new()
-local redis = require "lib/redis"
+local dataStore = require "lib/dataStore"
+local _M = {} 
+function _M.process (ds, token)
 
-function validateOAuthToken (red, token)
-
-  local key = utils.concatStrings({'oauth:provider:google:', token})
-  if redis.exists(red, key) == 1 then
-    redis.close(red)
-    return cjson.decode(redis.get(red, key))
-  end
+  local result = dataStore.getOAuthToken(ds, 'google', token) 
+  
+  local httpc = http.new()
+  if result ~= ngx.null then 
+    return cjson.decode(result)
+  end 
 
   local request_options = {
     headers = {
       ["Accept"] = "application/json"
     },
     ssl_verify = false
   }
+  
   local envUrl = os.getenv('TOKEN_GOOGLE_URL')
   envUrl = envUrl ~= nil and envUrl or 
'https://www.googleapis.com/oauth2/v3/tokeninfo'
   local request_uri = utils.concatStrings({envUrl, "?access_token=", token})
   local res, err = httpc:request_uri(request_uri, request_options)
 -- convert response
+--  local res = { expires = 30, token = 'abcdefg' }
 
 Review comment:
   remove comment here
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to