refactor(google-cloud-logging): unify google-cloud-oauth.lua file (#11596)

diff --git a/Makefile b/Makefile
index 545a21e..bd734ac 100644
--- a/Makefile
+++ b/Makefile
@@ -305,9 +305,6 @@
 	$(ENV_INSTALL) -d $(ENV_INST_LUADIR)/apisix/plugins/ext-plugin
 	$(ENV_INSTALL) apisix/plugins/ext-plugin/*.lua $(ENV_INST_LUADIR)/apisix/plugins/ext-plugin/
 
-	$(ENV_INSTALL) -d $(ENV_INST_LUADIR)/apisix/plugins/google-cloud-logging
-	$(ENV_INSTALL) apisix/plugins/google-cloud-logging/*.lua $(ENV_INST_LUADIR)/apisix/plugins/google-cloud-logging/
-
 	$(ENV_INSTALL) -d $(ENV_INST_LUADIR)/apisix/plugins/grpc-transcode
 	$(ENV_INSTALL) apisix/plugins/grpc-transcode/*.lua $(ENV_INST_LUADIR)/apisix/plugins/grpc-transcode/
 
diff --git a/apisix/plugins/google-cloud-logging.lua b/apisix/plugins/google-cloud-logging.lua
index 74360e9..62ca991 100644
--- a/apisix/plugins/google-cloud-logging.lua
+++ b/apisix/plugins/google-cloud-logging.lua
@@ -20,7 +20,7 @@
 local http            = require("resty.http")
 local log_util        = require("apisix.utils.log-util")
 local bp_manager_mod  = require("apisix.utils.batch-processor-manager")
-local google_oauth    = require("apisix.plugins.google-cloud-logging.oauth")
+local google_oauth    = require("apisix.utils.google-cloud-oauth")
 
 
 local lrucache = core.lrucache.new({
@@ -43,7 +43,7 @@
                     default = "https://oauth2.googleapis.com/token"
                 },
                 -- https://developers.google.com/identity/protocols/oauth2/scopes#logging
-                scopes = {
+                scope = {
                     type = "array",
                     items = {
                         description = "Google OAuth2 Authorization Scopes",
@@ -58,6 +58,15 @@
                         "https://www.googleapis.com/auth/cloud-platform"
                     }
                 },
+                scopes = {
+                    type = "array",
+                    items = {
+                        description = "Google OAuth2 Authorization Scopes",
+                        type = "string",
+                    },
+                    minItems = 1,
+                    uniqueItems = true
+                },
                 entries_uri = {
                     type = "string",
                     default = "https://logging.googleapis.com/v2/entries:write"
@@ -168,7 +177,9 @@
         return nil, err
     end
 
-    return google_oauth:new(auth_conf, conf.ssl_verify)
+    auth_conf.scope = auth_conf.scopes or auth_conf.scope
+
+    return google_oauth.new(auth_conf, conf.ssl_verify)
 end
 
 
diff --git a/apisix/plugins/google-cloud-logging/oauth.lua b/apisix/plugins/google-cloud-logging/oauth.lua
deleted file mode 100644
index a560bd4..0000000
--- a/apisix/plugins/google-cloud-logging/oauth.lua
+++ /dev/null
@@ -1,137 +0,0 @@
---
--- Licensed to the Apache Software Foundation (ASF) under one or more
--- contributor license agreements.  See the NOTICE file distributed with
--- this work for additional information regarding copyright ownership.
--- The ASF licenses this file to You under the Apache License, Version 2.0
--- (the "License"); you may not use this file except in compliance with
--- the License.  You may obtain a copy of the License at
---
---     http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing, software
--- distributed under the License is distributed on an "AS IS" BASIS,
--- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--- See the License for the specific language governing permissions and
--- limitations under the License.
---
-
-local core = require("apisix.core")
-local type = type
-local setmetatable = setmetatable
-
-local ngx_update_time = ngx.update_time
-local ngx_time = ngx.time
-local ngx_encode_args = ngx.encode_args
-
-local http = require("resty.http")
-local jwt = require("resty.jwt")
-
-
-local function get_timestamp()
-    ngx_update_time()
-    return ngx_time()
-end
-
-
-local _M = {}
-
-
-function _M:generate_access_token()
-    if not self.access_token or get_timestamp() > self.access_token_expire_time - 60 then
-        self:refresh_access_token()
-    end
-    return self.access_token
-end
-
-
-function _M:refresh_access_token()
-    local http_new = http.new()
-    local res, err = http_new:request_uri(self.token_uri, {
-        ssl_verify = self.ssl_verify,
-        method = "POST",
-        body = ngx_encode_args({
-            grant_type = "urn:ietf:params:oauth:grant-type:jwt-bearer",
-            assertion = self:generate_jwt_token()
-        }),
-        headers = {
-            ["Content-Type"] = "application/x-www-form-urlencoded",
-        },
-    })
-
-    if not res then
-        core.log.error("failed to refresh google oauth access token, ", err)
-        return
-    end
-
-    if res.status ~= 200 then
-        core.log.error("failed to refresh google oauth access token: ", res.body)
-        return
-    end
-
-    res, err = core.json.decode(res.body)
-    if not res then
-        core.log.error("failed to parse google oauth response data: ", err)
-        return
-    end
-
-    self.access_token = res.access_token
-    self.access_token_type = res.token_type
-    self.access_token_expire_time = get_timestamp() + res.expires_in
-end
-
-
-function _M:generate_jwt_token()
-    local payload = core.json.encode({
-        iss = self.client_email,
-        aud = self.token_uri,
-        scope = self.scope,
-        iat = get_timestamp(),
-        exp = get_timestamp() + (60 * 60)
-    })
-
-    local jwt_token = jwt:sign(self.private_key, {
-        header = { alg = "RS256", typ = "JWT" },
-        payload = payload,
-    })
-
-    return jwt_token
-end
-
-
-function _M:new(config, ssl_verify)
-    local oauth = {
-        client_email = config.client_email,
-        private_key = config.private_key,
-        project_id = config.project_id,
-        token_uri = config.token_uri or "https://oauth2.googleapis.com/token",
-        auth_uri = config.auth_uri or "https://accounts.google.com/o/oauth2/auth",
-        entries_uri = config.entries_uri or "https://logging.googleapis.com/v2/entries:write",
-        access_token = nil,
-        access_token_type = nil,
-        access_token_expire_time = 0,
-    }
-
-    oauth.ssl_verify = ssl_verify
-
-    if config.scopes then
-        if type(config.scopes) == "string" then
-            oauth.scope = config.scopes
-        end
-
-        if type(config.scopes) == "table" then
-            oauth.scope = core.table.concat(config.scopes, " ")
-        end
-    else
-        -- https://developers.google.com/identity/protocols/oauth2/scopes#logging
-        oauth.scope = core.table.concat({ "https://www.googleapis.com/auth/logging.read",
-                                          "https://www.googleapis.com/auth/logging.write",
-                                          "https://www.googleapis.com/auth/logging.admin",
-                                          "https://www.googleapis.com/auth/cloud-platform" }, " ")
-    end
-
-    setmetatable(oauth, { __index = self })
-    return oauth
-end
-
-
-return _M
diff --git a/docs/en/latest/plugins/google-cloud-logging.md b/docs/en/latest/plugins/google-cloud-logging.md
index 4a8313b..85b9723 100644
--- a/docs/en/latest/plugins/google-cloud-logging.md
+++ b/docs/en/latest/plugins/google-cloud-logging.md
@@ -42,7 +42,8 @@
 | auth_config.project_id  | True     |                                                                                                                                                                                                      | Project ID in the Google Cloud service account.                                                                                                                    |
 | auth_config.token_uri   | True    | https://oauth2.googleapis.com/token                                                                                                                                                                  | Token URI of the Google Cloud service account.                                                                                                                     |
 | auth_config.entries_uri | False    | https://logging.googleapis.com/v2/entries:write                                                                                                                                                      | Google Cloud Logging Service API.                                                                                                                                  |
-| auth_config.scopes      | False    | ["https://www.googleapis.com/auth/logging.read", "https://www.googleapis.com/auth/logging.write", "https://www.googleapis.com/auth/logging.admin", "https://www.googleapis.com/auth/cloud-platform"] | Access scopes of the Google Cloud service account. See [OAuth 2.0 Scopes for Google APIs](https://developers.google.com/identity/protocols/oauth2/scopes#logging). |
+| auth_config.scope       | False    | ["https://www.googleapis.com/auth/logging.read", "https://www.googleapis.com/auth/logging.write", "https://www.googleapis.com/auth/logging.admin", "https://www.googleapis.com/auth/cloud-platform"] | Access scopes of the Google Cloud service account. See [OAuth 2.0 Scopes for Google APIs](https://developers.google.com/identity/protocols/oauth2/scopes#logging). |
+| auth_config.scopes      | Deprecated    | ["https://www.googleapis.com/auth/logging.read", "https://www.googleapis.com/auth/logging.write", "https://www.googleapis.com/auth/logging.admin", "https://www.googleapis.com/auth/cloud-platform"] | Access scopes of the Google Cloud service account. Use `auth_config.scope` instead.                                                                           |
 | auth_file               | True     |                                                                                                                                                                                                      | Path to the Google Cloud service account authentication JSON file. Either `auth_config` or `auth_file` must be provided.                                           |
 | ssl_verify              | False    | true                                                                                                                                                                                                 | When set to `true`, enables SSL verification as mentioned in [OpenResty docs](https://github.com/openresty/lua-nginx-module#tcpsocksslhandshake).                  |
 | resource                | False    | {"type": "global"}                                                                                                                                                                                   | Google monitor resource. See [MonitoredResource](https://cloud.google.com/logging/docs/reference/v2/rest/v2/MonitoredResource) for more details.                   |
@@ -141,7 +142,7 @@
                 "client_email":"your service account email@apisix.iam.gserviceaccount.com",
                 "private_key":"-----BEGIN RSA PRIVATE KEY-----your private key-----END RSA PRIVATE KEY-----",
                 "token_uri":"https://oauth2.googleapis.com/token",
-                "scopes":[
+                "scope":[
                     "https://www.googleapis.com/auth/logging.admin"
                 ],
                 "entries_uri":"https://logging.googleapis.com/v2/entries:write"
diff --git a/docs/zh/latest/plugins/google-cloud-logging.md b/docs/zh/latest/plugins/google-cloud-logging.md
index d0e0ba5..d485bee 100644
--- a/docs/zh/latest/plugins/google-cloud-logging.md
+++ b/docs/zh/latest/plugins/google-cloud-logging.md
@@ -42,7 +42,8 @@
 | auth_config.project_id  | 是       |                                                  | 谷歌服务帐号的项目 ID。                                                                                                            |
 | auth_config.token_uri   | 是       | https://oauth2.googleapis.com/token              | 请求谷歌服务帐户的令牌的 URI。                                                                                                     |
 | auth_config.entries_uri | 否       | https://logging.googleapis.com/v2/entries:write  | 谷歌日志服务写入日志条目的 API。                                                                                                   |
-| auth_config.scopes      | 否       |                                                  | 谷歌服务账号的访问范围,可参考 [OAuth 2.0 Scopes for Google APIs](https://developers.google.com/identity/protocols/oauth2/scopes#logging)。可选项:"https://www.googleapis.com/auth/logging.read"、"https://www.googleapis.com/auth/logging.write"、"https://www.googleapis.com/auth/logging.admin"、"https://www.googleapis.com/auth/cloud-platform"。|
+| auth_config.scope       | 否       |                                                  | 谷歌服务账号的访问范围,可参考 [OAuth 2.0 Scopes for Google APIs](https://developers.google.com/identity/protocols/oauth2/scopes#logging)。可选项:"https://www.googleapis.com/auth/logging.read"、"https://www.googleapis.com/auth/logging.write"、"https://www.googleapis.com/auth/logging.admin"、"https://www.googleapis.com/auth/cloud-platform"。|
+| auth_config.scopes      | 废弃     |                                                  | 谷歌服务账号的访问范围,推荐使用 `auth_config.scope`                                                                               |
 | auth_file               | 是       |                                                  | `auth_config` 和 `auth_file` 必须配置一个。                                                                 |
 | ssl_verify              | 否       | true                                             | 当设置为 `true` 时,启用 `SSL` 验证。                 |
 | resource                | 否       | {"type": "global"}                               | 谷歌监控资源,请参考 [MonitoredResource](https://cloud.google.com/logging/docs/reference/v2/rest/v2/MonitoredResource)。             |
@@ -142,7 +143,7 @@
                 "client_email":"your service account email@apisix.iam.gserviceaccount.com",
                 "private_key":"-----BEGIN RSA PRIVATE KEY-----your private key-----END RSA PRIVATE KEY-----",
                 "token_uri":"https://oauth2.googleapis.com/token",
-                "scopes":[
+                "scope":[
                     "https://www.googleapis.com/auth/logging.admin"
                 ],
                 "entries_uri":"https://logging.googleapis.com/v2/entries:write"
diff --git a/t/plugin/google-cloud-logging.t b/t/plugin/google-cloud-logging.t
index bc4293c..81e7190 100644
--- a/t/plugin/google-cloud-logging.t
+++ b/t/plugin/google-cloud-logging.t
@@ -44,7 +44,7 @@
                 resource = {
                     type = "global"
                 },
-                scopes = {
+                scope = {
                     "https://www.googleapis.com/auth/logging.admin"
                 },
                 log_id = "syslog",
@@ -82,7 +82,7 @@
                 resource = {
                     type = "global"
                 },
-                scopes = {
+                scope = {
                     "https://www.googleapis.com/auth/logging.admin"
                 },
                 log_id = "syslog",
@@ -205,7 +205,7 @@
 -----END RSA PRIVATE KEY-----]],
                             project_id = "apisix",
                             token_uri = "http://127.0.0.1:1980/google/logging/token",
-                            scopes = {
+                            scope = {
                                 "https://apisix.apache.org/logs:admin"
                             },
                             entries_uri = "http://127.0.0.1:1980/google/logging/entries",
@@ -382,7 +382,7 @@
 -----END PRIVATE KEY-----]],
                             project_id = "apisix",
                             token_uri = "http://127.0.0.1:1980/google/logging/token",
-                            scopes = {
+                            scope = {
                                 "https://apisix.apache.org/logs:admin"
                             },
                             entries_uri = "http://127.0.0.1:1980/google/logging/entries",
@@ -465,7 +465,7 @@
 -----END PRIVATE KEY-----]],
                             project_id = "apisix",
                             token_uri = "http://127.0.0.1:1980/google/logging/token?token_type=Basic",
-                            scopes = {
+                            scope = {
                                 "https://apisix.apache.org/logs:admin"
                             },
                             entries_uri = "http://127.0.0.1:1980/google/logging/entries?token_type=Basic",
@@ -548,7 +548,7 @@
 -----END PRIVATE KEY-----]],
                             project_id = "apisix",
                             token_uri = "http://127.0.0.1:1980/google/logging/token?token_type=Basic",
-                            scopes = {
+                            scope = {
                                 "https://apisix.apache.org/logs:admin"
                             },
                             entries_uri = "http://127.0.0.1:1980/google/logging/entries",
diff --git a/t/plugin/google-cloud-logging/config-https-domain.json b/t/plugin/google-cloud-logging/config-https-domain.json
index cae0859..7225446 100644
--- a/t/plugin/google-cloud-logging/config-https-domain.json
+++ b/t/plugin/google-cloud-logging/config-https-domain.json
@@ -2,7 +2,7 @@
   "private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDDzrFwnA3EvYyR\naeMgaLD3hBjvxKrz10uox1X8q7YYhf2ViRtLRUMa2bEMYksE5hbhwpNf6mKAnLOC\nUuAT6cPPdUl/agKpJXviBPIR2LuzD17WsLJHp1HxUDssSkgfCaGcOGGNfLUhhIpF\n2JUctLmxiZoAZySlSjcwupSuDJ0aPm0XO8r9H8Qu5kF2Vkz5e5bFivLTmvzrQTe4\nv5V1UI6hThElCSeUmdNF3uG3wopxlvq4zXgLTnuLbrNf/Gc4mlpV+UDgTISj32Ep\nAB2vxKEbvQw4ti8YJnGXWjxLerhfrszFw+V8lpeduiDYA44ZFoVqvzxeIsVZNtcw\nIu7PvEPNAgMBAAECggEAVpyN9m7A1F631/aLheFpLgMbeKt4puV7zQtnaJ2XrZ9P\nPR7pmNDpTu4uF3k/D8qrIm+L+uhVa+hkquf3wDct6w1JVnfQ93riImbnoKdK13ic\nDcEZCwLjByfjFMNCxZ/gAZca55fbExlqhFy6EHmMjhB8s2LsXcTHRuGxNI/Vyi49\nsxECibe0U53aqdJbVWrphIS67cpwl4TUkN6mrHsNuDYNJ9dgkpapoqp4FTFQsBqC\nafOK5qgJ68dWZ47FBUng+AZjdCncqAIuJxxItGVQP6YPsFs+OXcivIVHJr363TpC\nl85FfdvqWV5OGBbwSKhNwiTNUVvfSQVmtURGWG/HbQKBgQD4gZ1z9+Lx19kT9WTz\nlw93lxso++uhAPDTKviyWSRoEe5aN3LCd4My+/Aj+sk4ON/s2BV3ska5Im93j+vC\nrCv3uPn1n2jUhWuJ3bDqipeTW4n/CQA2m/8vd26TMk22yOkkqw2MIA8sjJ//SD7g\ntdG7up6DgGMP4hgbO89uGU7DAwKBgQDJtkKd0grh3u52Foeh9YaiAgYRwc65IE16\nUyD1OJxIuX/dYQDLlo5KyyngFa1ZhWIs7qC7r3xXH+10kfJY+Q+5YMjmZjlL8SR1\nUjqd02R9F2//6OeswyReachJZbZdtiEw3lPa4jVFYfhSe0M2ZPxMwvoXb25eyCNI\n1lYjSKq87wKBgHnLTNghjeDp4UKe6rNYPgRm0rDrhziJtX5JeUov1mALKb6dnmkh\nGfRK9g8sQqKDfXwfC6Z2gaMK9YaryujGaWYoCpoPXtmJ6oLPXH4XHuLh4mhUiP46\nxn8FEfSimuQS4/FMxH8A128GHQSI7AhGFFzlwfrBWcvXC+mNDsTvMmLxAoGARc+4\nupppfccETQZ7JsitMgD1TMwA2f2eEwoWTAitvlXFNT9PYSbYVHaAJbga6PLLCbYF\nFzAjHpxEOKYSdEyu7n/ayDL0/Z2V+qzc8KarDsg/0RgwppBbU/nUgeKb/U79qcYo\ny4ai3UKNCS70Ei1dTMvmdpnwXwlxfNIBufB6dy0CgYBMYq9Lc31GkC6PcGEEbx6W\nvjImOadWZbuOVnvEQjb5XCdcOsWsMcg96PtoeuyyHmhnEF1GsMzcIdQv/PHrvYpK\nYp8D0aqsLEgwGrJQER26FPpKmyIwvcL+nm6q5W31PnU9AOC/WEkB6Zs58hsMzD2S\nkEJQcmfVew5mFXyxuEn3zA==\n-----END PRIVATE KEY-----",
   "project_id": "apisix",
   "token_uri": "https://test.com:1983/google/logging/token",
-  "scopes": [
+  "scope": [
     "https://apisix.apache.org/logs:admin"
   ],
   "entries_uri": "https://test.com:1983/google/logging/entries"
diff --git a/t/plugin/google-cloud-logging/config-https-ip.json b/t/plugin/google-cloud-logging/config-https-ip.json
index 498618f..86b33fc 100644
--- a/t/plugin/google-cloud-logging/config-https-ip.json
+++ b/t/plugin/google-cloud-logging/config-https-ip.json
@@ -2,7 +2,7 @@
   "private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDDzrFwnA3EvYyR\naeMgaLD3hBjvxKrz10uox1X8q7YYhf2ViRtLRUMa2bEMYksE5hbhwpNf6mKAnLOC\nUuAT6cPPdUl/agKpJXviBPIR2LuzD17WsLJHp1HxUDssSkgfCaGcOGGNfLUhhIpF\n2JUctLmxiZoAZySlSjcwupSuDJ0aPm0XO8r9H8Qu5kF2Vkz5e5bFivLTmvzrQTe4\nv5V1UI6hThElCSeUmdNF3uG3wopxlvq4zXgLTnuLbrNf/Gc4mlpV+UDgTISj32Ep\nAB2vxKEbvQw4ti8YJnGXWjxLerhfrszFw+V8lpeduiDYA44ZFoVqvzxeIsVZNtcw\nIu7PvEPNAgMBAAECggEAVpyN9m7A1F631/aLheFpLgMbeKt4puV7zQtnaJ2XrZ9P\nPR7pmNDpTu4uF3k/D8qrIm+L+uhVa+hkquf3wDct6w1JVnfQ93riImbnoKdK13ic\nDcEZCwLjByfjFMNCxZ/gAZca55fbExlqhFy6EHmMjhB8s2LsXcTHRuGxNI/Vyi49\nsxECibe0U53aqdJbVWrphIS67cpwl4TUkN6mrHsNuDYNJ9dgkpapoqp4FTFQsBqC\nafOK5qgJ68dWZ47FBUng+AZjdCncqAIuJxxItGVQP6YPsFs+OXcivIVHJr363TpC\nl85FfdvqWV5OGBbwSKhNwiTNUVvfSQVmtURGWG/HbQKBgQD4gZ1z9+Lx19kT9WTz\nlw93lxso++uhAPDTKviyWSRoEe5aN3LCd4My+/Aj+sk4ON/s2BV3ska5Im93j+vC\nrCv3uPn1n2jUhWuJ3bDqipeTW4n/CQA2m/8vd26TMk22yOkkqw2MIA8sjJ//SD7g\ntdG7up6DgGMP4hgbO89uGU7DAwKBgQDJtkKd0grh3u52Foeh9YaiAgYRwc65IE16\nUyD1OJxIuX/dYQDLlo5KyyngFa1ZhWIs7qC7r3xXH+10kfJY+Q+5YMjmZjlL8SR1\nUjqd02R9F2//6OeswyReachJZbZdtiEw3lPa4jVFYfhSe0M2ZPxMwvoXb25eyCNI\n1lYjSKq87wKBgHnLTNghjeDp4UKe6rNYPgRm0rDrhziJtX5JeUov1mALKb6dnmkh\nGfRK9g8sQqKDfXwfC6Z2gaMK9YaryujGaWYoCpoPXtmJ6oLPXH4XHuLh4mhUiP46\nxn8FEfSimuQS4/FMxH8A128GHQSI7AhGFFzlwfrBWcvXC+mNDsTvMmLxAoGARc+4\nupppfccETQZ7JsitMgD1TMwA2f2eEwoWTAitvlXFNT9PYSbYVHaAJbga6PLLCbYF\nFzAjHpxEOKYSdEyu7n/ayDL0/Z2V+qzc8KarDsg/0RgwppBbU/nUgeKb/U79qcYo\ny4ai3UKNCS70Ei1dTMvmdpnwXwlxfNIBufB6dy0CgYBMYq9Lc31GkC6PcGEEbx6W\nvjImOadWZbuOVnvEQjb5XCdcOsWsMcg96PtoeuyyHmhnEF1GsMzcIdQv/PHrvYpK\nYp8D0aqsLEgwGrJQER26FPpKmyIwvcL+nm6q5W31PnU9AOC/WEkB6Zs58hsMzD2S\nkEJQcmfVew5mFXyxuEn3zA==\n-----END PRIVATE KEY-----",
   "project_id": "apisix",
   "token_uri": "https://127.0.0.1:1983/google/logging/token",
-  "scopes": [
+  "scope": [
     "https://apisix.apache.org/logs:admin"
   ],
   "entries_uri": "https://127.0.0.1:1983/google/logging/entries"
diff --git a/t/plugin/google-cloud-logging/config.json b/t/plugin/google-cloud-logging/config.json
index 8de2535..3d0bb62 100644
--- a/t/plugin/google-cloud-logging/config.json
+++ b/t/plugin/google-cloud-logging/config.json
@@ -2,7 +2,7 @@
   "private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDDzrFwnA3EvYyR\naeMgaLD3hBjvxKrz10uox1X8q7YYhf2ViRtLRUMa2bEMYksE5hbhwpNf6mKAnLOC\nUuAT6cPPdUl/agKpJXviBPIR2LuzD17WsLJHp1HxUDssSkgfCaGcOGGNfLUhhIpF\n2JUctLmxiZoAZySlSjcwupSuDJ0aPm0XO8r9H8Qu5kF2Vkz5e5bFivLTmvzrQTe4\nv5V1UI6hThElCSeUmdNF3uG3wopxlvq4zXgLTnuLbrNf/Gc4mlpV+UDgTISj32Ep\nAB2vxKEbvQw4ti8YJnGXWjxLerhfrszFw+V8lpeduiDYA44ZFoVqvzxeIsVZNtcw\nIu7PvEPNAgMBAAECggEAVpyN9m7A1F631/aLheFpLgMbeKt4puV7zQtnaJ2XrZ9P\nPR7pmNDpTu4uF3k/D8qrIm+L+uhVa+hkquf3wDct6w1JVnfQ93riImbnoKdK13ic\nDcEZCwLjByfjFMNCxZ/gAZca55fbExlqhFy6EHmMjhB8s2LsXcTHRuGxNI/Vyi49\nsxECibe0U53aqdJbVWrphIS67cpwl4TUkN6mrHsNuDYNJ9dgkpapoqp4FTFQsBqC\nafOK5qgJ68dWZ47FBUng+AZjdCncqAIuJxxItGVQP6YPsFs+OXcivIVHJr363TpC\nl85FfdvqWV5OGBbwSKhNwiTNUVvfSQVmtURGWG/HbQKBgQD4gZ1z9+Lx19kT9WTz\nlw93lxso++uhAPDTKviyWSRoEe5aN3LCd4My+/Aj+sk4ON/s2BV3ska5Im93j+vC\nrCv3uPn1n2jUhWuJ3bDqipeTW4n/CQA2m/8vd26TMk22yOkkqw2MIA8sjJ//SD7g\ntdG7up6DgGMP4hgbO89uGU7DAwKBgQDJtkKd0grh3u52Foeh9YaiAgYRwc65IE16\nUyD1OJxIuX/dYQDLlo5KyyngFa1ZhWIs7qC7r3xXH+10kfJY+Q+5YMjmZjlL8SR1\nUjqd02R9F2//6OeswyReachJZbZdtiEw3lPa4jVFYfhSe0M2ZPxMwvoXb25eyCNI\n1lYjSKq87wKBgHnLTNghjeDp4UKe6rNYPgRm0rDrhziJtX5JeUov1mALKb6dnmkh\nGfRK9g8sQqKDfXwfC6Z2gaMK9YaryujGaWYoCpoPXtmJ6oLPXH4XHuLh4mhUiP46\nxn8FEfSimuQS4/FMxH8A128GHQSI7AhGFFzlwfrBWcvXC+mNDsTvMmLxAoGARc+4\nupppfccETQZ7JsitMgD1TMwA2f2eEwoWTAitvlXFNT9PYSbYVHaAJbga6PLLCbYF\nFzAjHpxEOKYSdEyu7n/ayDL0/Z2V+qzc8KarDsg/0RgwppBbU/nUgeKb/U79qcYo\ny4ai3UKNCS70Ei1dTMvmdpnwXwlxfNIBufB6dy0CgYBMYq9Lc31GkC6PcGEEbx6W\nvjImOadWZbuOVnvEQjb5XCdcOsWsMcg96PtoeuyyHmhnEF1GsMzcIdQv/PHrvYpK\nYp8D0aqsLEgwGrJQER26FPpKmyIwvcL+nm6q5W31PnU9AOC/WEkB6Zs58hsMzD2S\nkEJQcmfVew5mFXyxuEn3zA==\n-----END PRIVATE KEY-----",
   "project_id": "apisix",
   "token_uri": "http://127.0.0.1:1980/google/logging/token",
-  "scopes": [
+  "scope": [
     "https://apisix.apache.org/logs:admin"
   ],
   "entries_uri": "http://127.0.0.1:1980/google/logging/entries"
diff --git a/t/plugin/google-cloud-logging2.t b/t/plugin/google-cloud-logging2.t
index 11e8628..35d162b 100644
--- a/t/plugin/google-cloud-logging2.t
+++ b/t/plugin/google-cloud-logging2.t
@@ -125,7 +125,7 @@
 -----END PRIVATE KEY-----]],
                             project_id = "apisix",
                             token_uri = "http://127.0.0.1:1980/google/logging/token",
-                            scopes = {
+                            scope = {
                                 "https://apisix.apache.org/logs:admin"
                             },
                             entries_uri = "http://127.0.0.1:1980/google/logging/entries",
@@ -244,7 +244,7 @@
 -----END PRIVATE KEY-----]],
                             project_id = "apisix",
                             token_uri = "http://127.0.0.1:1980/google/logging/token",
-                            scopes = {
+                            scope = {
                                 "https://apisix.apache.org/logs:admin"
                             },
                             entries_uri = "http://127.0.0.1:1980/google/logging/entries",
@@ -384,7 +384,7 @@
 -----END PRIVATE KEY-----]],
                             project_id = "apisix",
                             token_uri = "http://127.0.0.1:1980/google/logging/token",
-                            scopes = {
+                            scope = {
                                 "https://apisix.apache.org/logs:admin"
                             },
                             entries_uri = "http://127.0.0.1:1980/google/logging/entries",