์๋
ํ์ธ์, Firebase ๊ธฐ๋ฅ ๋ฐฐํฌ๋ฅผ ์๋ํํ๋ ค๊ณ ํฉ๋๋ค. "GOOGLE_APPLICATION_CREDENTIALS=
3.18.5
์ปจํ ์ด๋ ๋ ธ๋:6.14-alpine
/usr/bin/docker run --rm -v /workspace:/workspace -e GOOGLE_APPLICATION_CREDENTIALS=
์ธ์ฆ๋ฐ๊ธฐ ์ํด
[2018-05-29T15:57:32.507Z] > ๋ช
๋ น์๋ ๋ฒ์๊ฐ ํ์ํฉ๋๋ค. [โemailโ,โopenidโ,โhttps://www.googleapis.com/auth/cloudplatformprojects.readonlyโ,โhttps://www .googleapis.com/auth/firebaseโ]
[2018-05-29T15:57:32.507Z] > ์ฑ ๊ธฐ๋ณธ ์๊ฒฉ ์ฆ๋ช
์ ํตํด ์ธ์ฆ ์๋
[2018-05-29T15:57:32.547Z] ! ์๋ ์ธ์ฆ ์ค๋ฅ: ์ด ์์ฒญ์๋ ๋ฒ์๊ฐ ํ์ํฉ๋๋ค.
[2018-05-29T15:57:32.547Z] > ์๊ฒฉ ์ฆ๋ช
์ ์ฐพ๊ฑฐ๋ ์๋์ผ๋ก ๊ฒ์ํ ์ ์์ต๋๋ค.
๋ช ๊ฐ์ง ์ ์ ์ฌํญ์ด ์์ต๋๊น?
์๋ ํ์ธ์, ํ์ํ ์๊ฒฉ ์ฆ๋ช ์ GOOGLE_APPLICATION_CREDENTIALS๊ฐ ์๋๋ฏ๋ก ํด๋น ์ค์ด ์ค์ ๋ก ๋์์ด ๋์ง ์์ต๋๋ค.
CI ํ ํฐ์ ์์ฑํ ๋ค์ --token ํ๋๊ทธ์ ํจ๊ป ๋ช ๋ น์ ์คํํด์ผ ํฉ๋๋ค. ์์ธํ ๋ด์ฉ์ https://github.com/firebase/firebase-tools#using -with-ci-systems๋ฅผ ์ฐธ์กฐํ์ธ์.
์๋
ํ์ธ์,
https://github.com/firebase/firebase-tools/pull/417์ ์ด๋ป์ต๋๊น?
GOOGLE_APPLICATION_CREDENTIALS๊ฐ ๊ตฌํ๋๊ณ firebase-tools๊ฐ ์ด๋ฅผ ์ป๊ธฐ ์ํด google-auto-auth๋ฅผ ์ฌ์ฉํ๋ ๊ฒ ๊ฐ์ต๋๋ค.
์๋๋ฉด ๋ด๊ฐ ํ๋ ธ์ด?
Google ์ฌ์ฉ์(GSuite ๋๋ Cloud ID ๋ฑ)๊ฐ ์๋ ์๋น์ค ๊ณ์ ์ผ๋ก ์ธ์ฆํ๊ณ ์ถ๊ธฐ ๋๋ฌธ์ CI ํ ํฐ์ ์ฌ์ฉํ์ง ์์ต๋๋ค.
๊ฐ์ฌํฉ๋๋ค
์๋
ํ์ธ์,
๋ผ์ด๋ธ๋ฌ๋ฆฌ๊ฐ firebase-public.firebaseio๋ฅผ ํธ์ถํ๋ ๊ฒ ๊ฐ์ต๋๋ค. com:443 ์ด๊ณ HTTP ๋ฐํ ์ฝ๋๋ 200์ด์ง๋ง ์๋ต์ 0๋ฐ์ดํธ์
๋๋ค.
์๋ ํ์ธ์, ๋น์ ์ด ๋ง์ต๋๋ค. ์ฃ์กํฉ๋๋ค, ๊ทธ ํ๋ณด๋ฅผ ์์ด๋ฒ๋ ธ์ต๋๋ค. ๋๋ ์ด๊ฒ์ ์ต์ํ์ง ์์ต๋๋ค. ๋ง์ดํด, ์ฌ๋ฌด์ค์ ๋์์ค๋ฉด ์ข ๋ด์ฃผ์๊ฒ ์ด์?
์๋
ํ์ธ์ @laurenzlong @mbleigh ,
์๋น์ค ๊ณ์ ์ ๋ํด "Domain Wide Authority"๋ฅผ ๊ตฌ์ฑํ๋ฉด ์ธ์ฆ์ด ํ์ฉ๋๋ค๋ ๊ฒ์ ์์์ต๋๋ค.
๊ทธ๋ฌ๋ ์ด์ ๋ค์๊ณผ ๊ฐ์ ๋ฌธ์ ๊ฐ ์์ต๋๋ค.
GOOGLE_APPLICATION_CREDENTIALS=<path_to_json> firebase deploy --only functions --non-interactive --project=<project_id> --debug
[2018-06-04T09:25:46.202Z] ----------------------------------------------------------------------
[2018-06-04T09:25:46.211Z] CLI Version: 3.18.5
[2018-06-04T09:25:46.212Z] Platform: linux
[2018-06-04T09:25:46.212Z] Node Version: v6.14.2
[2018-06-04T09:25:46.212Z] Time: Mon Jun 04 2018 09:25:46 GMT+0000 (UTC)
[2018-06-04T09:25:46.213Z] ----------------------------------------------------------------------
[2018-06-04T09:25:46.238Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[2018-06-04T09:25:46.238Z] > attempting to authenticate via app default credentials
[2018-06-04T09:25:46.445Z] xxxx.x.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-xx
[2018-06-04T09:25:46.446Z] > retrieved access token via default credentials
[2018-06-04T09:25:46.449Z] >>> HTTP REQUEST GET https://admin.firebase.com/v1/projects/<project_id>
Mon Jun 04 2018 09:25:46 GMT+0000 (UTC)
[2018-06-04T09:25:47.067Z] <<< HTTP RESPONSE 404 server=nginx, date=Mon, 04 Jun 2018 09:25:47 GMT, content-type=application/json; charset=utf-8, content-length=87, connection=close, x-content-type-options=nosniff
[2018-06-04T09:25:47.069Z] <<< HTTP RESPONSE BODY code=PROJECT_NOT_FOUND, message=The specified project was not found.
์๋น์ค ๊ณ์ ์ ํ๋ก์ ํธ์ ๋ํ ํธ์ง์ ๊ถํ์ด ์์ผ๋ฉฐ svc ๊ณ์ ์ด ์๋ Google ID๋ฅผ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ ๋ฌธ์ ๊ฐ ์กด์ฌํ์ง ์์ต๋๋ค.
์ด ๋น์ทํ ๋ฌธ์ ๋ฅผ ์ฐพ์์ง๋ง (ํ ํฐ์ ์ฌ์ฉํฉ๋๋ค) https://github.com/firebase/firebase-tools/issues/744
๊ฐ์ฌ ํด์
์๋, ๋ด๊ฐ ํ๋ ธ์ด.
Firebase ์ฌ์ฉ์ ์คํํ๋ฉด ๋ค์ ๋ค์์ ์ํํฉ๋๋ค.
[2018-06-04T14:39:38.660Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase"]
[2018-06-04T14:39:38.660Z] > attempting to authenticate via app default credentials
[2018-06-04T14:39:38.693Z] ! auto-auth error: Scopes are required for this request.
[2018-06-04T14:39:38.694Z] > no credentials could be found or automatically retrieved
Owner
์ญํ ์ด ํ ๋น๋ ์๋น์ค ๊ณ์ ์ด firebase
CLI ๋๊ตฌ๋ฅผ ์ฌ์ฉํ์ฌ ๋ฌด์์ด๋ ํ๋ ค๊ณ ํ๋ ๊ฒฝ์ฐ์๋ ๋์ผํ ๋์:
$ export GOOGLE_APPLICATION_CREDENTIALS=account.json
$ firebase list --debug
[2018-06-05T12:15:17.340Z] ----------------------------------------------------------------------
[2018-06-05T12:15:17.343Z] Command: /usr/local/bin/node /usr/local/bin/firebase list --debug
[2018-06-05T12:15:17.343Z] CLI Version: 3.18.5
[2018-06-05T12:15:17.343Z] Platform: linux
[2018-06-05T12:15:17.343Z] Node Version: v10.3.0
[2018-06-05T12:15:17.343Z] Time: Tue Jun 05 2018 12:15:17 GMT+0000 (UTC)
[2018-06-05T12:15:17.343Z] ----------------------------------------------------------------------
[2018-06-05T12:15:17.347Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase"]
[2018-06-05T12:15:17.348Z] > attempting to authenticate via app default credentials
[2018-06-05T12:15:17.352Z] ! auto-auth error: Scopes are required for this request.
[2018-06-05T12:15:17.352Z] > no credentials could be found or automatically retrieved
Error: Command requires authentication, please run firebase login
์ฌ์ํ ๋จ์๋ ์ก์ธ์ค ํ ํฐ์ด ๋น์ด ์๋ค๋ ๊ฒ์ ๋๋ค(๊ฐ์ ๋ฌธ์ ๊ฐ ์๊ณ JWT๋ฅผ ๋์ฝ๋ฉํ์ต๋๋ค).
๊ทธ ํํ์์ ์์
xxxx.x.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
์ค๊ฐ x๋ ๋ฐ์ดํฐ ํ์ด๋ก๋์ด๊ณ ํฌ๊ธฐ๊ฐ 1์์ด๋ฏ๋ก ๋ถ๋ช ํ ๊ฐ๋ ์ฐจ์ง ์์ต๋๋ค.
firebase-tools๋ google-auto-auth๋ฅผ ์ฌ์ฉํ์ฌ ํ ํฐ์ ๊ฐ์ ธ์ค๋ฏ๋ก ๋ฌธ์ ๊ฐ ์์ ์ ์๋ค๊ณ ์๊ฐํฉ๋๋ค.
์ด๋ฐ, ์ ๋ฒ์ ( 3.18.6
)์ ์ฌ์ ํ authScopes
์ autoAuth()
๋ก ์ ๋ฌํ์ง ์๋ ๊ฒ ๊ฐ์ต๋๋ค. ์ด ์ค ์์ ๋ก๊ทธ ๋ฌธ์ ์ถ๊ฐํ๋ ๊ฒฝ์ฐ: https://github.com/firebase/firebase-tools/blob/b2594467d8980c5a1e2b8c4aff3de9877a98b42b/lib/requireAuth.js#L21
authScopes: undefined
๋ฐ์ต๋๋ค.
๋ด๊ฐ ์ถ๊ฐํ๋ฉด
authScopes = [
scopes.EMAIL,
scopes.OPENID,
scopes.CLOUD_PROJECTS_READONLY,
scopes.FIREBASE_PLATFORM,
];
๊ทธ ์ค ์ด์ ์ ์ก์ธ์ค ํ ํฐ ํ๋์ ์งํํ์ง๋ง PROJECT_NOT_FOUND
์คํจํฉ๋๋ค.
๋ํ @tomlarkworthy , ํด๋น OAuth ํ ํฐ์ JWT๊ฐ ์๋๋ฏ๋ก ์ค๊ฐ ๋ถ๋ถ์ ํฌํจํ์ง ์์์ผ ํฉ๋๋ค. https://developers.google.com/apis-explorer/#search/oauth2/oauth2/v2/oauth2.tokeninfo ์์ ์คํํ๋ฉด "scope": "https://www.googleapis.com/auth/cloudplatformprojects.readonly https://www.googleapis.com/auth/plus.me https://www.googleapis.com/auth/firebase https://www.googleapis.com/auth/userinfo.email",
์ ํจ๊ป ์ ํจํ ํ ํฐ์ผ๋ก ๋ณด๊ณ ๋ฉ๋๋ค.
๊ฐ์ฌ ํด์! ํ์ธ ๊ทธ๋์ ํ๋ก์ ํธ๋ฅผ ์ฐพ์ ์ ์์ต๋๋ค ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค. ํ ํฐ์ ๋์ฝ๋ฉํ ๋ " https://www.googleapis.com/auth/cloud-platform " ๋ฒ์๊ฐ ํ๋๋ง ์์ต๋๋ค.
"์ ์์ ์ธ"ํ ํฐ (์ ํตํด ํ๋ ์ฆ, ํ๋์ ์ฐจ์ด๊ฐ firebase login
) :
{
"issued_to": "563584335869-fgrhgmd47bqnekij5i8b5pr03ho849e6.apps.googleusercontent.com",
"audience": "563584335869-fgrhgmd47bqnekij5i8b5pr03ho849e6.apps.googleusercontent.com",
"user_id": "xxxyyy",
"scope": "https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/cloudplatformprojects.readonly https://www.googleapis.com/auth/firebase https://www.googleapis.com/auth/plus.me",
"expires_in": 3484,
"email": "[email protected]",
"verified_email": true,
"access_type": "offline"
}
์๋น์ค ๊ณ์ (SA)์์ ์์ฑ๋ ๊ณ์ :
{
"issued_to": "1160xxxx",
"audience": "1160xxxx",
"user_id": "1160xxxx",
"scope": "https://www.googleapis.com/auth/cloudplatformprojects.readonly https://www.googleapis.com/auth/plus.me https://www.googleapis.com/auth/firebase https://www.googleapis.com/auth/userinfo.email",
"expires_in": 3563,
"email": "[email protected]",
"verified_email": true,
"access_type": "offline"
}
๋ฐ๋ผ์ ํ ํฐ์ https://github.com/firebase/firebase-tools/blob/376678fef91f71de5859f14d8374b2d8d2731980/์ ์์ด์ผ ํ๋ ์ฌ๋ฐ๋ฅธ audience
๋ฐ user_id
๋ฐํ๋์ง ์์ ๊ฒ์ผ๋ก ๋ณด์
๋๋ค. lib/api.js#L84
@tomlarkworth๋ ์ฌ์ ํ ์ด์ํฉ๋๋ค. ์ฌ๋ฐ๋ฅธ ๋ฒ์๋ฅผ ๋ช
์์ ์ผ๋ก ์ถ๊ฐํ์ง ์๋ ํ ๋ด authScope
๋ undefined
์
๋๋ค. ์ด ํญ๋ชฉ์ ์คํํ๊ธฐ ์ ์ firebase logout
๋ฅผ ์คํํ์ต๋๊น?
ํด๋ผ์ด์ธํธ ID๋ oath2 ํด๋ผ์ด์ธํธ์ด๋ฉฐ ์๋ํ ์ ์๋ ๋งค์ฐ ๊ตฌ์ฒด์ ์ธ ๋๋ฉ์ธ์ด ์์ผ๋ฏ๋ก ์ฐ๋ฆฌ์ ์์ด ๋ฟ์ง ์๋ ๊ณณ์ ๊ตฌ์ฑ๋ฉ๋๋ค. ๋ฐ/๋๋ localhost์์ ์ฌ์ฉ์ ์ํธ ์์ฉ์ด ํ์ํฉ๋๋ค. ๋ฐ๋ผ์ CI์์ ์น์ธ์ ๋ฐ๊ธฐ๊ฐ ๋งค์ฐ ์ด๋ ต์ต๋๋ค.
๋ด ๊ธฐ๋ฅ์ ์คํํ๊ณ ์์ต๋๋ค. ๋๋ ๋น์ ๊ณผ ๊ฐ์ ์ค๋ฅ๊ฐ ์์์ต๋๋ค. ์๋ณธ ํฌ์คํฐ์ฒ๋ผ ์ฐพ์ ์ ์๋ ํ๋ก์ ํธ๊ฐ ์์ต๋๋ค.
์๋น์ค ๊ณ์ ์์ ์์ฒด ํ ํฐ์ ๊ตฌ์ฑํ๊ณ --token๊ณผ ํจ๊ป ์ ๋ฌํ๋ฉด ๋ค์์ ์ป์ต๋๋ค.
HTTP ์๋ต 401 vary=X-Origin, Origin,Accept-Encoding, www-authenticate=Bearer realm=" https://accounts.google.com/ ", content-type=application/json; charset=UTF-8, ๋ ์ง=๋ชฉ, 2018๋
6์ 7์ผ 00:16:43 GMT, ๋ง๋ฃ=๋ชฉ, 2018๋
6์ 7์ผ 00:16:43 GMT, cache-control=private, max-age=0, x-content- type-options=nosniff, x-frame-options=SAMEORIGIN, x-xss-protection=1; ๋ชจ๋=๋ธ๋ก, ์๋ฒ=GSE, Alt-svc=quic=":443"; ma=2592000; v="43,42,41,39,35", ํ์ฉ ๋ฒ์=์์, ์ฐ๊ฒฐ=๋ซ๊ธฐ
[2018-06-07T00:16:43.786Z] <<< HTTP RESPONSE BODY error=unauthorized_client, error_description=Unauthorized
[2018-06-07T00:16:43.791Z] > ๋ช
๋ น์๋ ๋ฒ์๊ฐ ํ์ํฉ๋๋ค. ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www .googleapis.com/auth/firebase"]
[2018-06-07T00:16:43.792Z] > --token ์ต์
์ ํตํ ๊ถํ ๋ถ์ฌ
[2018-06-07T00:16:43.792Z] > ๋ฒ์๊ฐ ์๋ ์ก์ธ์ค ํ ํฐ ์๋ก ๊ณ ์นจ: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https:/ /www.googleapis.com/auth/firebase"]
[2018-06-07T00:16:43.793Z] >>> HTTP ์์ฒญ ๊ฒ์๋ฌผ https://www.googleapis.com/oauth2/v3/token
{ ์๋ก๊ณ ์นจ ํ ํฐ: 'ya29.c.XXXXXXXXXXXX',
client_id: '563584335869-fgrhgmd47bqnekij5i8b5pr03ho849e6.apps.googleusercontent.com',
client_secret: 'j9iVZfS8kkCEFUPaAeJV0sAi',
Grant_type: '์๋ก๊ณ ์นจ_ํ ํฐ',
๋ฒ์: '์ด๋ฉ์ผ openid https://www.googleapis.com/auth/cloudplatformprojects.readonly https://www.googleapis.com/auth/firebase ' }
์ด ๋งน์ธ ํด๋ผ์ด์ธํธ ID๊ฐ ๋ฐฉํด๊ฐ ๋๋ค๊ณ ์๊ฐํฉ๋๊น?
@tomlarkworthy ๋ฐ๋์ ์ด๋ ต์ง๋ ์์ต๋๋ค - ์ง๊ธ clientId
๊ตฌ์ฑ์ ํ
์คํธํ๊ณ ์์ต๋๋ค.
์, ๋ค์ ๊ฐ์ ์ฌ์ ์ํ ์ ์์ต๋๋ค.
https://github.com/firebase/firebase-tools/blob/376678fef91f71de5859f14d8374b2d8d2731980/lib/api.js
์์ฒด oauth ํด๋ผ์ด์ธํธ๋ก ๋ง์ถค ํ๋ก์ ํธ๋ฅผ ๋ง๋ค๊ณ firebase-tools client_id ๋ฐ secret_id๋ฅผ ์ฌ์ ์ํ์ต๋๋ค. ๊ทธ๋ผ ํ ํฐ์ ๋ณต์ฌ ๋งน์ธ ์น ์์ฉ ํ๋ก๊ทธ๋จ์ autheorized ๋ฐ ์คํฌ ๊ธฐ์ง-๋๊ตฌ๋ฅผ ํธ์ถํ๋ ๋ฐ ์ฌ์ฉํ๋ค. ์ฝ๊ฐ ๋ค๋ฅธ ๊ฒฝ๋ก๋ก ์ด๋ํ์ฌ ์ฑ๊ณต์ ์ผ๋ก ํ ํฐ์ ์๋ก ๊ณ ์ณค์ง๋ง ํ๋ก์ ํธ ๋ชฉ๋ก์ ๊ฐ์ ธ์ค์ง ๋ชปํ์ต๋๋ค. ํ ํฐ ๋์ฝ๋์์ cloudplatformprojects ์ฝ๊ธฐ ์ ์ฉ ๋ฒ์๊ฐ ์์ผ๋ฏ๋ก ์ฝ์ ์ ์์ด์ผ ํจ์ ํ์ธํ์ต๋๋ค.
์ ๋ณด: ํ์ค ์ค๋ฅ: [2018-06-07T01:02:21.126Z] ํ๊ฒฝ ์ฌ์ ์: FIREBASE_CLIENT_ID, FIREBASE_CLIENT_SECRET
[2018-06-07T01:02:21.126Z] -------------------------------------- --------------------------------
์ ๋ณด: stderr: [2018-06-07T01:02:21.138Z] > ๋ช ๋ น์ ๋ฒ์ ํ์: ["email","openid"," https://www.googleapis.com/auth/cloudplatformprojects.readonly "," https ://www.googleapis.com/auth/firebase "," https://www.googleapis.com/auth/cloud-platform "]
์ ๋ณด: stderr: [2018-06-07T01:02:21.138Z] > --token ์ต์
์ ํตํ ๊ถํ ๋ถ์ฌ
[2018-06-07T01:02:21.140Z] > ๋ฒ์๊ฐ ์๋ ์ก์ธ์ค ํ ํฐ ์๋ก ๊ณ ์นจ: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https:/ /www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[2018-06-07T01:02:21.140Z] >>> HTTP ์์ฒญ ๊ฒ์๋ฌผ https://www.googleapis.com/oauth2/v3/token
{ ์๋ก๊ณ ์นจ_ํ ํฐ: 'ya29.XXX',
client_id: '278696186940-fbqtl733l62g4qj8aekr4i66cpo0k5c1.apps.googleusercontent.com',
client_secret: 'XXXX',
Grant_type: '์๋ก๊ณ ์นจ_ํ ํฐ',
๋ฒ์: '์ด๋ฉ์ผ openid https://www.googleapis.com/auth/cloudplatformprojects.readonly https://www.googleapis.com/auth/firebase https://www.googleapis.com/auth/cloud-platform ' }
2018๋
6์ 6์ผ ์์์ผ 18:02:21 GMT-0700(PDT)
์ ๋ณด: ํ์ค ์ค๋ฅ: [2018-06-07T01:02:21.318Z] <<< HTTP ์๋ต 200 x-google-netmon-label=/bns/ph/borg/ph/bns/apiserving/prod_hightraffic_api_frontend.server/998, x -google-gfe-backend-request-info=eid=HYQYW5jODYyytgbB3JfoAg, cache-control=no-cache, no-store, max-age=0, must-revalidate, pragma=no-cache, expires=Mon, 1990๋ 1์ 1์ผ 00:00:00 GMT, ๋ ์ง=Thu, 2018๋ 6์ 7์ผ 01:02:21 GMT, vary=X-Origin, Origin, Accept-Encoding, x-google-session-info=GgIYBiAB, content-type=application/json ; charset=UTF-8, x-content-type-options=nosniff, x-frame-options=SAMEORIGIN, x-xss-protection=1; ๋ชจ๋=๋ธ๋ก, ์๋ฒ=GSE, x-google-servertype=apiserving, x-google-gfe-request-trace=acsfoh11:443,phnm21-v6:9897,/bns/ph/borg/ph/bns/apiserving/prod_hightraffic_api_frontend .server/998,phnm21-v6:9897,acsfoh11:443, x-google-gslb-service=apiserving-hightraffic, x-google-backends=plbn61:9882,/bns/ph/borg/ph/bns/apiserving/ prod_hightraffic_api_frontend.server/998,phnm21-v6:9897,/bns/ph/borg/ph/bns/traffic-prod/shared-layer2-gfe/495,acsfoh11:443, x-google-dos-service-trace= ๊ธฐ๋ณธ :identity-o-auth-2-service-migration , main:shared-layer2-gfe , x-google-service=identity-o-auth-2-service-migration,restricted-shared-layer2-grpc-aggregate, x -google-gfe-response-code-details-trace=response_code_set_by_backend,response_code_set_by_backend, x-google-gfe-response-body-transformations=gunzipped, x-google-shellfish-status=CA0gBEBG, alt-svc=quic=":443 "; ma=2592000; v="43,42,41,39,35", x-google-gfe-service-trace=identity-o-auth-2-service-migration,restricted-shared-layer2-grpc-aggregate, ํ์ฉ ๋ฒ์= ์์, ์ฐ๊ฒฐ=๋ซ๊ธฐ
์ ๋ณด: ํ์ค ์ค๋ฅ: [2018-06-07T01:02:21.319Z] >>> HTTP ์์ฒญ GET https://admin.firebase.com/v1/projects/docsite-go
2018๋ 6์ 6์ผ ์์์ผ 18:02:21 GMT-0700(PDT)
์ ๋ณด: ํ์ค ์ค๋ฅ: [2018-06-07T01:02:21.652Z] <<< HTTP ์๋ต 404 ์๋ฒ=nginx, ๋ ์ง=Thu, 07 Jun 2018 01:02:21 GMT, content-type=application/json; charset=utf-8, ๋ด์ฉ ๊ธธ์ด=87, ์ฐ๊ฒฐ=๋ซ๊ธฐ, x-content-type-options=nosniff
์ ๋ณด: ํ์ค ์ค๋ฅ: [2018-06-07T01:02:21.652Z] <<< HTTP RESPONSE BODY ์ฝ๋=PROJECT_NOT_FOUND, ๋ฉ์์ง=์ง์ ํ ํ๋ก์ ํธ๋ฅผ ์ฐพ์ ์ ์์ต๋๋ค.
Firebase๋ ํ์ฌ ๊ณ ๊ฐ ํ๋ก์ ํธ์ ๋ณ๋๋ก ์ฌ์ ์ ์๋ ํด๋ผ์ด์ธํธ๋ฅผ ์ฌ์ฉํ๊ธฐ ๋๋ฌธ์ @tomlarkworthy ์ฌ์ฉ์ ์ ์ ๊ฐ์ผ๋ก client_id ๋ฐ secret์ ์ฌ์ ์ํ๋ ๊ฒ์ ์๋ํ์ง ์์ต๋๋ค(์ ์ด๋ ๋ด ์ดํด).
๋ํ --token
์ต์
์ ์๋ก ๊ณ ์นจ ํ ํฐ๋ง ์ง์ํ๋ฉฐ ์๋น์ค ๊ณ์ ์ด ์๋ ๊ฒฝ์ฐ์๋ ์ป์ ์ ์์ต๋๋ค(๋ค์ ๋งํ์ง๋ง ์ ๊ฐ ์ดํดํ๋ ํ).
๊ฐ๋ฅํ ๊ฒฝ์ฐ ์ด ํด๋ผ์ด์ธํธ ID๋ก SA ์ก์ธ์ค ํ ํฐ์ ์์ฑํ๋ ๊ฐ๋จํ ๋ฐฉ๋ฒ์ ์ฐพ์์ผ ํฉ๋๋ค.
https://developers.google.com/identity/protocols/OAuth2ServiceAccount#jwt -auth์ ์ค๋ช ๋ ๋๋ก ๋์ฒด ๊ฒฝ๋ก๋ก ์ด๋ํ์ฌ OAuth ํ ํฐ ๋์ ํด๋ผ์ด์ธํธ JWT๋ฅผ ์ฌ์ฉํ์ฌ Firebase API๋ฅผ ํธ์ถํ ์ ์์ต๋๋ค.
stephenplusplus/google-auto-auth ์์ ๋ด๋ถ์ ์ผ๋ก ์ฌ์ฉํ๋ google/google-auth-library-nodejs ๋ ์ด๋ฅผ ์ํํ๋ ๋ ํธ๋ฆฌํ๊ณ ์์ ํ ๋ฐฉ๋ฒ์ ์ ๊ณตํฉ๋๋ค.
๋๋ ์ฐ๋ฆฌ๊ฐ ๋ฐ์ ํ ์ ์๋ค๊ณ ์๊ฐํ์ง ์์ต๋๋ค.
https://github.com/firebase/firebase-tools/issues/647#issuecomment -361926336 ์ด์ ์ ์ฑ๊ณต์ ๋ณด๊ณ ํ ๊ฒ์ผ๋ก ๋ณด์ด์ง๋ง ํ์ธ๋์๋์ง ํ์คํ์ง ์์ต๋๋ค. ๋ฌธ์ ์ Firebase API(https://admin.firebase.com/v1/projects)๊ฐ private ์ธ ๊ฒ์ผ๋ก ๋ณด์ด๋ฉฐ ํด๋น ํด๋ผ์ด์ธํธ ID์ ๋ํด ์์ฑ๋ ํ ํฐ๋ง ํ์ฉํฉ๋๋ค.
์๋ง๋ ์ด๊ฒ์ ๊ธฐ๋ฅ ์์ฒญ์ผ๋ก ์ ์ถํด์ผ ํฉ๋๋ค. ๋ฐฐํฌ์ ์๋น์ค ๊ณ์ ์ ์ฌ์ฉํ ์ ์๋ ๊ธฐ๋ฅ์ด ์์ผ๋ฉด ๋จ์ผ ์๊ฒฉ ์ฆ๋ช ์ ์ฌ์ฉํ์ฌ(๋ชจ๋ ์ฌ์ฉ์๋ก๋ถํฐ ๋ถ๋ฆฌ๋จ) Firebase์ GCP ๋ฆฌ์์ค๋ฅผ ๋ชจ๋ ๋ฐฐํฌํ ์ ์์ต๋๋ค.
CLI์ --token
์ต์
์ ์ก์ธ์ค ํ ํฐ์ด ์๋๋ผ ์๋ก ๊ณ ์นจ ํ ํฐ์ ์ ๋ฌํ๊ธฐ ์ํ ๊ฒ์
๋๋ค. firebase login:ci
์์ ์์ฑ๋ ๊ฒ์
๋๋ค.
์๋น์ค ๊ณ์ ์น์ธ์ ๊ด๋ฒ์ํ๊ฒ ํ
์คํธํ์ง๋ ์์์ง๋ง admin.firebase.com
๋ฐฑ์๋์์ ๊ด๋ฒ์ํ ๊ถํ์ด ํ์ํ IAM ๊ฒ์ฌ๊ฐ ๋ฐ์ํ ์ ์๋ค๊ณ ์๊ฐํฉ๋๋ค. ๋ ์์ธํ ์กฐ์ฌํ ์ ์์ง๋ง ์ฌ๊ธฐ์์ ๋ฐ๋์ ์ด๊ณ ์ ํด๊ฒฐ์ ๊ธฐ๋ํ์ง๋ ์์ต๋๋ค.
CLI์ --token ์ต์ ์ ์๋ก ๊ณ ์นจ ํ ํฐ์ ์ ๋ฌํ๊ธฐ ์ํ ๊ฒ์ ๋๋ค.
๋ค, ์์ ๊ฐ์ด ์ดํดํฉ๋๋ค.
SA ํค๋ฅผ ์ฌ์ฉํ์ฌ CI ํ๊ฒฝ์์ ๋ฐฐํฌํ๋ ๊ฒ์ ๋๋ผ์ด ์ผ์
๋๋ค. ์๋ก ๊ณ ์นจ ํ ํฐ์ ํน์ ์ฌ์ฉ์์๊ฒ ์ฐ๊ฒฐ๋์ด ์์ผ๋ฉฐ ๋ค๋ฅธ GCP ์๋น์ค๋ฅผ ๊ด๋ฆฌํ๊ธฐ ์ํด gcloud
๋ช
๋ น์ ์ธ์ฆํ๋ ๋ฐ ์ด ํ ํฐ์ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ์ด ๋ช
ํํ์ง ์์ต๋๋ค. ํ์ฌ ๋ ๊ฐ์ง ์ ํ์ ์๊ฒฉ ์ฆ๋ช
(Firebase CLI์ฉ ๊ด๋ฆฌ์ ์๋ก ๊ณ ์นจ ํ ํฐ ๋ฐ gcloud
์ฉ SA ํค)์ ์ ๊ณตํด์ผ ํฉ๋๋ค.
์๋น์ค ๊ณ์ ์ ๋ํด ์์ฑ๋ ํ ํฐ์ ์ฌ์ฉํ์ฌ FIREBASE_TOKEN='<token_here>' firebase deploy --only firestore,storage
(๋ค๋ฅธ ๋์์ ์๋ํ์ง ์์์ผ๋ฉฐ ์๋ํ ์ ์์)ํ ์ ์์ต๋๋ค.
์ค์ ํ ํฐ์ " https://www.googleapis.com/auth/cloud-platform " ๋ฒ์ ์ ๋ณผํธ์ GCP ๋น๋ฐ ์์ง์ ์ํด ์๋น์ค ๊ณ์ ์ ๋ํด ์์ฑ๋์์ต๋๋ค.
์ต์ Firebase CLI์ ํจ๊ป SA ํค + GOOGLE_APPLICATION_CREDENTIALS๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์ด ๋ถ๊ฐ๋ฅํจ์ ํ์ธํฉ๋๋ค. ๋ชจ๋ ๋ช ๋ น์ ๋ค์๊ณผ ๊ฐ์ด ์ข ๋ฃ๋ฉ๋๋ค.
root<strong i="6">@frontend</strong>:/usr/src/app$ firebase list
Error: HTTP Error: 404, The specified project was not found.
Having trouble? Try firebase list --help
@cpic ํฅ๋ฏธ
@paolomainardi firebase list
๋ ๋ ๊ฑฐ์ ํ๋ก์ ํธ ๋ชฉ๋ก ๊ตฌํ์ ์์กดํ๊ธฐ ๋๋ฌธ์ SA ํค๋ก ์๋ํ์ง ์์ต๋๋ค. ๊ทธ๋ฌ๋ ๋ค๋ฅธ ๋ชจ๋ ๊ฒ์ ๊ทธ๋ ๊ฒ ํด์ผ ํฉ๋๋ค(๋จผ์ ๋ช ๊ฐ์ง API๋ฅผ ํ์ฑํํด์ผ ํ ์๋ ์์). ๋ค๋ฅธ ๋ช
๋ น์ ์๋ํ๊ณ ํ์ธํ๋ ๊ฒ์ด ์ข์ต๋๋ค.
์ฐ๋ฆฌ๋ GOOGLE_APPLICATION_CREDENTIALS
๋ช ๊ฐ์ง ํ๋ฅญํ ์ฌ์ฉ ์ฌ๋ก๋ฅผ ์ ๊ณตํ๋ค๊ณ ์๊ฐํ๊ธฐ ๋๋ฌธ์ ๋ง์ ์ด๋ ค์์ ๊ฒช์ง ์๊ณ ์์ ํ ์ง์์ ์ป๊ธฐ ์ํด ๋
ธ๋ ฅํ๊ณ ์์ต๋๋ค.
@paolomainardi vault
๊ตฌํ์ด ์ฌ๊ธฐ์ ์๋ค๊ณ ์๊ฐ ํฉ๋๋ค(์ฝ๋๋ฅผ ๋น ๋ฅด๊ฒ ๊ฒ์ํ ํ์ ์ถ์ธก์ผ ๋ฟ์
๋๋ค).
๋๋ ๋ํ ๊ทธ๊ฒ์ด gcloud alpha iam service-accounts sign-jwt
๊ฐ ํ๋ ๊ฒ๊ณผ ๊ฐ์ ๊ฒ์ด๋ผ๊ณ ์๊ฐ ํฉ๋๋ค(๋ค์ ๋งํ์ง๋ง, ๋ค์ ๊ต์ก๋ฐ์ ์ถ์ธก).
@cpick์ ๊ฐ์ฌ๋๋ฆฝ๋๋ค. ๊ณ์ํด์ ์์์ ์ ํ๊ฒ ์ต๋๋ค.
๋๋ ์ด๊ฒ์ ๊ฐ๋จํ ์ดํด๋ณด๊ณ ํ
์คํธ๋ก ์๋น์ค ๊ณ์ ์๊ฒฉ ์ฆ๋ช
๊ณผ access_token
๋ฅผ requireAuth.js ์ ๊ฐ์ ๋ก ๋ฃ์ผ๋ ค๊ณ ํ์ต๋๋ค.
์ ์ด๋ ๋ฌด์ธ๊ฐ๊ฐ ์๋ํ๋ ๊ฒ์ ๋ณด๋ ค๊ณ ์๋ํฉ๋๋ค.
๊ทธ๊ฒ์ ์ ์ด์ CLI๋ ํญ์ ์๋๋ฅผ ๋ณด์ธ๋ค https://admin.firebase.com/v1/projects/
(๋น์ ์ ๋ด๊ฐ w /๋ฅผ ๋ฌด์์ ์๋ฏธ ํ ์์๋ค ์๊ด์์ด --debug
ํ๋๊ทธ. ๋ด๊ฐ์ด ๋ฌธ์ ์ ์ด์ ์ฝ๋ฉํธ๋ก ์ฝ๋๋ค๋ฉด, ๊ทธ๊ฒ์ ์๋ง๋ '์ ์ฐ์ svc ๊ณ์ ์์ ์๋ํ์ง ์๋ ' api ๋์ '.
๊ฐ๋จํ GET
ํธ์ถ๋ก ๋ค๋ฅธ ๋์ ์ ํ
์คํธํ๋๋ฐ ๊ด์ฐฎ์ ๊ฒ ๊ฐ์ต๋๋ค.
์ฌํ์ ์ํด
requireAuth.js
๋ฅผ ํ๋์ฝ๋ฉํ ์์ ์ ๋์ ๋ฒ์์ svc_accounts ์ก์ธ์ค ํ ํฐ์ ๋ฐํํฉ๋๋ค.function getServiceAccountClient() {
const credFile = '/path/to/cert.json';
const keys = require(credFile);
let client = new JWT(
keys.client_email,
null,
keys.private_key,
["email","openid","https://www.googleapis.com/auth/cloud-platform", "https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase"],
);
return client;
};
function _autoAuth(options, authScopes) {
return new Promise(function(resolve, reject) {
var client = getServiceAccountClient();
client.getAccessToken().then(res => {
console.log(res);
api.setAccessToken(res.token);
resolve();
}).catch(function (error) {
console.error('Unable to recall targetClient access_token ' + error);
});
/*
logger.debug("> attempting to authenticate via app default credentials");
......
const {JWT} = require('google-auth-library');
function getServiceAccountClient() {
const credFile = '/path/to/cert.json';
const keys = require(credFile);
let client = new JWT(
keys.client_email,
null,
keys.private_key,
["email","openid","https://www.googleapis.com/auth/cloud-platform", "https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase"],
);
return client;
};
var client = getServiceAccountClient();
let project_id = 'your_project';
let url = 'https://admin.firebase.com/v1/projects/' + project_id
//let url = "https://firestore.googleapis.com/v1beta1/projects/" + project_id + "/databases/(default)/indexes"
//let url = "https://firebaserules.googleapis.com/v1/projects/" + project_id + "/rulesets"
client.requestAsync({url}).then(resp => {
console.log(resp.data);
}).catch(function (error) {
console.error('Unable to list buckets: ' + error);
});
์ด ์์ง ์ ํ์๋ ๋๋ก firestore
, storage
๋ฐ hosting
์๋น์ค ๊ณ์ ์ ์ฌ์ฉํ์ฌ ๋ง์นจ๋ด ๋ฐฐํฌํ ์ ์์ต๋๋ค.
๋ค์์ functions
๋ฐฐํฌ์์ ์๋ํ์ง ์๊ธฐ ๋๋ฌธ์ ๊ธฐ๋ณธ์ ์ผ๋ก ํดํน์ด๋ฉฐ ๋ถ์์ ํฉ๋๋ค. ์์ mbleigh๊ฐ '์ผ๊ธ ์ง์'์ ๋ํด ์ธ๊ธํ ์ ์ฒด ์๋ฃจ์
์ ๊ธฐ๋ค๋ฆด ๊ฐ์น๊ฐ ์์ต๋๋ค.
์ด์จ๋ ๋ค์๊ณผ ๊ฐ์ด ํ์ธํ์ต๋๋ค.
gcloud
์ปจํ
์คํธ์์๋ Firebase ๊ณ์ ์ผ๋ก ์์ํฉ๋๋ค.
$ gcloud iam service-accounts list
NAME EMAIL
App Engine default service account [email protected]
firebase-adminsdk firebase-adminsdk-h2v8k@firebase-auth-sal.iam.gserviceaccount.com
gcloud iam service-accounts keys create `pwd`/svc.json --iam-account=firebase-adminsdk-h2v8k@firebase-auth-sal.iam.gserviceaccount.com
ํด๋น ํ๋ก์ ํธ์์ ์๋น์ค ๊ณ์ ์ OWNER
๋ก ์ถ๊ฐํฉ๋๋ค.
ํด๋ผ์ฐ๋ ์ฝ์๋ก ์ด๋ํ์ฌ ์ผ๋ถ API๋ฅผ ํ์ฑํํฉ๋๋ค.
https://console.developers.google.com/apis/api/cloudresourcemanager.googleapis.com/overview?project=<your_project>
https://console.developers.google.com/apis/api/firebasehosting.googleapis.com/overview?project=<your_project>
gcloud
๋ฐ firebase
$ firebase logout
โ Logged out from [email protected]
$ mv ~/.config/gcloud ~/.config/gcloud_backup
ADC
env-var ์ค์ ๋ฐ ๋ฐฐํฌexport GOOGLE_APPLICATION_CREDENTIALS=`pwd`/svc.json
$ firebase deploy -P firebase-auth-sal --only firestore,hosting,storage
{ token: 'ya29.c.EmJ8B....', res: null }
=== Deploying to 'firebase-auth-sal'...
i deploying storage, firestore, hosting
i storage: checking storage.rules for compilation errors...
โ storage: rules file storage.rules compiled successfully
i firestore: checking firestore.rules for compilation errors...
i firestore: reading indexes from firestore.indexes.json...
โ firestore: rules file firestore.rules compiled successfully
i storage: uploading rules storage.rules...
i firestore: uploading rules firestore.rules...
โ firestore: deployed indexes in firestore.indexes.json successfully
i hosting[fir-auth-sal]: beginning deploy...
i hosting[fir-auth-sal]: found 1 files in public
โ hosting[fir-auth-sal]: file upload complete
โ storage: released rules storage.rules to firebase.storage/firebase-auth-sal.appspot.com
โ firestore: released rules firestore.rules to cloud.firestore
i hosting[fir-auth-sal]: finalizing version...
โ hosting[fir-auth-sal]: version finalized
i hosting[fir-auth-sal]: releasing new version...
โ hosting[fir-auth-sal]: release complete
โ Deploy complete!
Project Console: https://console.firebase.google.com/project/firebase-auth-sal/overview
Hosting URL: https://fir-auth-sal.firebaseapp.com
functions
๋ฐฐํฌ ์๋functions
๋ฐฐํฌ ์ ํ์ ์๋ ํ์ฑํ ๊ฒ์ฌ๋ฅผ ์ฌ์ ์ํ๋ ค๊ณ ํด๋ ์๋ํ์ง ์์ต๋๋ค(๋ค๋ฅธ mobilesdk.googleapis.com
์๋ํฌ์ธํธ์ ์ก์ธ์คํ๋ฉด ์ค์ง๋ฉ๋๋ค. Firebase ๊ธฐ๋ฅ ๋ฐฐํฌ๊ฐ client_id
์ฐ๊ฒฐ๋์ด ์์ ์ ์์ต๋๋ค. Firebase ๊ธฐ๋ฅ์ ๊ฒฝ์ฐ
$ firebase deploy -P firebase-auth-sal --only functions --debug
[2018-12-24T01:36:44.034Z] >>> HTTP REQUEST GET https://servicemanagement.googleapis.com/v1/services/cloudfunctions.googleapis.com/projectSettings/firebase-auth-sal?view=CONSUMER_VIEW
[2018-12-24T01:36:44.034Z] >>> HTTP REQUEST GET https://servicemanagement.googleapis.com/v1/services/runtimeconfig.googleapis.com/projectSettings/firebase-auth-sal?view=CONSUMER_VIEW
[2018-12-24T01:36:44.486Z] <<< HTTP RESPONSE 404 vary=X-Origin, Referer, Origin,Accept-Encoding, content-type=application/json; charset=UTF-8, date=Mon, 24 Dec 2018 01:36:44 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="44,43,39,35", accept-ranges=none, connection=close
[2018-12-24T01:36:44.486Z] <<< HTTP RESPONSE BODY code=404, message=Method not found., status=NOT_FOUND
Error: HTTP Error: 404, Method not found.
[2018-12-24T01:36:44.495Z] Error Context: {
"body": {
"error": {
"code": 404,
"message": "Method not found.",
"status": "NOT_FOUND"
๋ด๋ถ ๋ฒ๊ทธ ์ฐธ์กฐ: 122552119
@tinaliang ์ด ๋ฌธ์ ์ ๋ํ ์ ๋ฐ์ดํธ๊ฐ ์์ต๋๊น? ์ธ์ฆ์ ์ํ ์๋น์ค ๊ณ์ ์ง์์ด ์ฐ์ ๋์ด์ผ ํ๋ค๊ณ ์๊ฐํฉ๋๋ค.
ํ์ฌ ์ ๋ฐ์ดํธ๊ฐ ์์ต๋๋ค...
์ง๋ ๋ ์ ๋ด ๋ฐ๊ฒฌ์ ํน๋ณํ Firebase ํด๋ผ์ฐ๋ ๊ธฐ๋ฅ์ด ํ์ํ์ง ์๊ธฐ ๋๋ฌธ์ ์์๋๋ก ์๋ํ๋ GCP ํด๋ผ์ฐ๋ ๊ธฐ๋ฅ https://cloud.google.com/functions/ ์ ์ฌ์ฉํ ์ ์๋ค๋ ๊ฒ์ ๋๋ค(๋ฐฐํฌ๋ gcloud CLI๋ฅผ ํตํด ์ํ๋จ) ๊ทธ๋ฌ๋ ์ด๊ฒ์ ์ค์ ํด๊ฒฐ ๋ฐฉ๋ฒ์ ์๋์ง๋ง ... ๋๊ตฐ๊ฐ์๊ฒ ๋์์ด ๋ ์ ์์ต๋๋ค. :)
#1175์ ์ํด ๋ณต์ ๋จ
์์ง ์
๋ฐ์ดํธ๊ฐ ์์ต๋๊น? Cloud Build๋ฅผ ํตํด Firebase ์ฑ์ ๋ฐฐํฌํ๋ ค๊ณ ํ์ต๋๋ค. hosting
๋ฑ์ด ์ ๋๋ก ์๋ํ๊ณ ๋ฐฐํฌ๋๋ ๊ฒ ๊ฐ์ต๋๋ค. functions
๊ฐ ์ฌ๋ฐ๋ฅด๊ฒ ๋ฐฐํฌ๋์ง ์๊ณ ์์์ ์ค๋ช
ํ ๋๋ก IAM ๋ด์์ ์ ์ ํ ๊ตฌ์ฑ์ผ๋ก 404
๊ฐ ํ์๋ฉ๋๋ค. (์๋น์ค ๊ณ์ cloudbuild
์๋ "Firebase Admin" ๋ฐ "API Keys Admin"์ ๋ํ ๊ถํ์ด ์์ต๋๋ค.) ์ด ํฐ์ผ์ ์ฐ์ ์์๊ฐ ๋์์ผ ํฉ๋๋ค ๐ฅ
์์ง ์ ๋ฐ์ดํธ๊ฐ ์์ง๋ง ๊ณง ์ดํด๋ณด๋๋ก ํ๊ฒ ์ต๋๋ค.
@mbleigh ์ด๋ค ์ ๋ฐ์ดํธ? ํ์ฌ Firebase CLI์์ ์๋น์ค ๊ณ์ ์ ์ฌ์ฉํ์ฌ ๋ฐฐํฌํ ์ ์์์ ํ์ธํ์๊ฒ ์ต๋๊น? ์ฐ๋ฆฌ๋ CI ๋๊ตฌ๋ฅผ ์ํฉ๋๋ค. ๊ทธ๋์ GOOGLE_APPLICATION_CREDENTIALS ์ง์์ด ์๋ํ์ง ์์ต๋๊น?
์ด์ ์ ์ธ๊ธํ๋ฏ์ด ๋ชจ๋ firebase
CLI ๋ช
๋ น์ด GOOGLE_APPLICATION_CREDENTIALS
์์ ์๋ํ๋ ๊ฒ์ ์๋์ง๋ง ์ข์ ์ซ์๋ ํด์ผ ํฉ๋๋ค. ์๋น์ค ๊ณ์ ์๊ฒฉ ์ฆ๋ช
์ ๊ฒฝ๋ก๋ก ์ค์ ํ๊ธฐ๋ง ํ๋ฉด ๋ฉ๋๋ค(์ฌ์ค, ๋ฌด์๋ณด๋ค๋ test-hosting.sh
์คํฌ๋ฆฝํธ๊ฐ ํ๋ ์ผ์
๋๋ค).
firebase login:ci
๋ฅผ ์ฌ์ฉํ๋ฉด CI ์์คํ
์์ ํ ํฐ ์ ํฉ๋๋ค.
GOOGLE_APPLICATION_CREDENTIALS
์ ์ฌ์ฉ๋ฒ๊ณผ ๊ธฐ๋ฅ์ ๊ณต์ํํ๋ ๊ฒ์ ์ฐ๋ฆฌ์ ๋ง์์ ์์ง๋ง ์ผ์ ์ ์ฝ์ํ ์๋ ์์ต๋๋ค. ๊ธฐ๋ค๋ ค ์ฃผ์
์ ๊ฐ์ฌํฉ๋๋ค.
์ด ๊ฒฝ์ฐ ์ธ์คํด์ค ๋ฉํ๋ฐ์ดํฐ ADC๊ฐ ์๋ํ๋์ง ์๋๋ฉด GOOGLE_APPLICATION_CREDENTIALS
๋ง ์๋ํ๋์ง ๋ช
ํํ ํด์ฃผ์ค ์ ์์ต๋๊น?
์ด ์ค๋ ๋์ ์๋ ๋ชจ๋ ์ฌ์ฉ์: ๋ชจํ์ฌ์ ๋๋ผ๊ณ ์๋ค๋ฉด #1463์ ๋ถ๊ธฐ๋ฅผ ์ฌ์ฉํด ๋ณด๊ณ ์๋น์ค ๊ณ์ ์ธ์ฆ์ผ๋ก ์ํ๋ ์์ ์ ์ํํ ์ ์๋์ง ํ์ธํ๊ณ ์ถ์ต๋๋ค. ์ฐ๋ฆฌ๊ฐ ๋๋ถ๋ถ์ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๋ค๊ณ ์๊ฐํ์ง๋ง ๊ทธ๋ฌํ ๋ฌธ์ ์ ๋ํ ์ธ๋ถ ํ ์คํธ๋ฅผ ๋ฐ๊ณ ์ถ์ต๋๋ค.
@mbleigh firebase apps:list web
๋ Cloud Build์ ์ ๋ฐ์ ๊ฐํ์ ์ผ๋ก ์คํจํฉ๋๋ค. ๋๋ฒ๊ทธ๋ก ์คํํ๋ฉด ์คํจ ์ด์ ์ ๋ํ ์ ๋ณด๊ฐ ์ ๊ณต๋์ง ์์ต๋๋ค. ๋ฌด์จ ์ผ์ด ์ผ์ด๋ ์ ์๋์ง์ ๋ํ ์ด๋ค ์๊ฐ์ด ์์ต๋๊น?
[2020-02-13T21:25:55.987Z] ----------------------------------------------------------------------
[2020-02-13T21:25:55.991Z] Command: /usr/local/bin/node /workspace/node_modules/.bin/firebase apps:list web -j --project=projectName --debug
[2020-02-13T21:25:55.991Z] CLI Version: 7.12.1
[2020-02-13T21:25:55.991Z] Platform: linux
[2020-02-13T21:25:55.991Z] Node Version: v10.18.0
[2020-02-13T21:25:55.992Z] Time: Thu Feb 13 2020 21:25:55 GMT+0000 (Coordinated Universal Time)
[2020-02-13T21:25:55.992Z] ----------------------------------------------------------------------
๋ํ @mbleigh firebase use projectName
๋ช
๋ น๋ ๋ฉํ๋ฐ์ดํฐ ์๋ฒ์์ ์ฌ๋ฐ๋ฅธ ์๊ฒฉ ์ฆ๋ช
์ ๊ฐ์ ธ ์ค์ง ๋ชปํ๊ธฐ ๋๋ฌธ์ ๊ฐํ์ ์ผ๋ก ์คํจํฉ๋๋ค.
[2020-02-13T21:49:41.050Z] ----------------------------------------------------------------------
[2020-02-13T21:49:41.055Z] Command: /usr/bin/node /directory/node_modules/.bin/firebase --debug use projectName
[2020-02-13T21:49:41.056Z] CLI Version: 7.12.1
[2020-02-13T21:49:41.056Z] Platform: linux
[2020-02-13T21:49:41.056Z] Node Version: v10.16.3
[2020-02-13T21:49:41.056Z] Time: Thu Feb 13 2020 21:49:41 GMT+0000 (Coordinated Universal Time)
[2020-02-13T21:49:41.056Z] ----------------------------------------------------------------------
[2020-02-13T21:49:41.057Z]
[2020-02-13T21:49:41.073Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[2020-02-13T21:49:41.073Z] > attempting to authenticate via app default credentials
[2020-02-13T21:49:41.669Z] TypeError: Cannot create property 'refresh_token' on string 'Not Found
'
at /directory/node_modules/google-auto-auth/node_modules/google-auth-library/lib/auth/oauth2client.js:208:28
at /directory/node_modules/google-auto-auth/node_modules/google-auth-library/lib/auth/computeclient.js:85:7
at Request._callback (/directory/node_modules/google-auto-auth/node_modules/google-auth-library/lib/transporters.js:106:7)
at Request.self.callback (/directory/node_modules/request/request.js:185:22)
at Request.emit (events.js:198:13)
at Request.EventEmitter.emit (domain.js:448:20)
at Request.<anonymous> (/directory/node_modules/request/request.js:1161:10)
at Request.emit (events.js:198:13)
at Request.EventEmitter.emit (domain.js:448:20)
at IncomingMessage.<anonymous> (/directory/node_modules/request/request.js:1083:12)
at Object.onceWrapper (events.js:286:20)
at IncomingMessage.emit (events.js:203:15)
at IncomingMessage.EventEmitter.emit (domain.js:448:20)
at endReadableNT (_stream_readable.js:1145:12)
at process._tickCallback (internal/process/next_tick.js:63:19)
10/02/20๋ถํฐ ์๋น์ค ๊ณ์ ์ ์ฌ์ฉํ ๋ Cloudbuild๋ฅผ ์ฌ์ฉํ์ฌ Firebase ํธ์คํ ์ ๋ฐฐํฌํ ๋ ๊ฐํ์ ์ธ ์ค๋ฅ๊ฐ ๋ฐ์ํ๊ธฐ ์์ํ์ต๋๋ค. ๊ทธ ์ ์๋ ํ๋์ ์ผ๊ด๋๊ฒ ๊ด์ฐฎ์๊ณ ์ด์ ๋ ์์ฃผ ์คํจํ๋ ๊ฒ ๊ฐ์ต๋๋ค. ์ด ์์ ์ ์ฑ๊ณต์ ์ผ๋ก ์ํํ ์ ์๋๋ก ์๋น์ค ๊ณ์ ์ ์์ํด์ผ ํ๋ ์๋ก์ด ๊ถํ ์งํฉ์ด ์๋์ง ๊ถ๊ธํฉ๋๋ค. ๋ด ๋ฐฐํฌ์ ๋๋ถ๋ถ์ด ๋จ์ํ ์คํจํ๋ ๊ฒ์ ์ฝ๊ฐ์ ๋ฌธ์ ๊ฐ ๋์์ต๋๋ค ๐
๋ค์์ ๋น๋์ ์์ ๊ฐ์๊ธฐ ์คํจํ๊ธฐ ์์ํ์ ๋์ ์คํฌ๋ฆฐ์ท์ ๋๋ค.
๋๋ฒ๊ทธ ์ค๋ฅ๋ ์์ ์ฃผ์๊ณผ ๋งค์ฐ ์ ์ฌํฉ๋๋ค.
[2020-02-16T07:30:46.905Z] ----------------------------------------------------------------------
[2020-02-16T07:30:46.908Z] Command: /usr/local/bin/node /home/node/.npm-global/bin/firebase deploy --only hosting -P project-production --debug
[2020-02-16T07:30:46.908Z] CLI Version: 7.8.1
[2020-02-16T07:30:46.908Z] Platform: linux
[2020-02-16T07:30:46.909Z] Node Version: v12.13.1
[2020-02-16T07:30:46.909Z] Time: Sun Feb 16 2020 07:30:46 GMT+0000 (Coordinated Universal Time)
[2020-02-16T07:30:46.910Z] ----------------------------------------------------------------------
[2020-02-16T07:30:46.910Z]
[2020-02-16T07:30:46.920Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[2020-02-16T07:30:46.920Z] > attempting to authenticate via app default credentials
[2020-02-16T07:30:47.023Z] TypeError: Cannot create property 'refresh_token' on string 'Not Found
'
at /home/node/.npm-global/lib/node_modules/firebase-tools/node_modules/google-auto-auth/node_modules/google-auth-library/lib/auth/oauth2client.js:208:28
at /home/node/.npm-global/lib/node_modules/firebase-tools/node_modules/google-auto-auth/node_modules/google-auth-library/lib/auth/computeclient.js:85:7
at Request._callback (/home/node/.npm-global/lib/node_modules/firebase-tools/node_modules/google-auto-auth/node_modules/google-auth-library/lib/transporters.js:106:7)
at Request.self.callback (/home/node/.npm-global/lib/node_modules/firebase-tools/node_modules/request/request.js:185:22)
at Request.emit (events.js:210:5)
at Request.EventEmitter.emit (domain.js:475:20)
at Request.<anonymous> (/home/node/.npm-global/lib/node_modules/firebase-tools/node_modules/request/request.js:1161:10)
at Request.emit (events.js:210:5)
at Request.EventEmitter.emit (domain.js:475:20)
at IncomingMessage.<anonymous> (/home/node/.npm-global/lib/node_modules/firebase-tools/node_modules/request/request.js:1083:12)
at Object.onceWrapper (events.js:299:28)
at IncomingMessage.emit (events.js:215:7)
at IncomingMessage.EventEmitter.emit (domain.js:475:20)
at endReadableNT (_stream_readable.js:1184:12)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
Error: An unexpected error has occurred.
์ด๊ฒ์ https://github.com/firebase/firebase-tools/issues/1970 (์ฆ, ์ด์ gcloud Auth์์ ์ฌ์ ํ ์ฌ์ฉ๋๋ ์ด์ v1beta1
์ธ์คํด์ค ๋ฉํ๋ฐ์ดํฐ ์๋ํฌ์ธํธ์ ์ง์ ์ค๋จ)๊ณผ ๊ด๋ จ์ด ์๋ ๊ฒ ๊ฐ์ต๋๋ค. Firebase CLI์์ ์ฌ์ฉํ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ..)
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
@mbleigh ์ด๋ค ์ ๋ฐ์ดํธ? ํ์ฌ Firebase CLI์์ ์๋น์ค ๊ณ์ ์ ์ฌ์ฉํ์ฌ ๋ฐฐํฌํ ์ ์์์ ํ์ธํ์๊ฒ ์ต๋๊น? ์ฐ๋ฆฌ๋ CI ๋๊ตฌ๋ฅผ ์ํฉ๋๋ค. ๊ทธ๋์ GOOGLE_APPLICATION_CREDENTIALS ์ง์์ด ์๋ํ์ง ์์ต๋๊น?