{"id":259,"date":"2020-05-17T19:13:09","date_gmt":"2020-05-17T10:13:09","guid":{"rendered":"http:\/\/localhost:8000\/?p=259"},"modified":"2021-01-17T12:47:56","modified_gmt":"2021-01-17T03:47:56","slug":"chrome-extension-firebase-google-authentication","status":"publish","type":"post","link":"http:\/\/localhost:8000\/2020\/05\/chrome-extension-firebase-google-authentication.html","title":{"rendered":"Chrome\u62e1\u5f35\uff0bFirebase\u3067Google\u8a8d\u8a3c\u3059\u308b\u3044\u304f\u3064\u304b\u306e\u65b9\u6cd5"},"content":{"rendered":"
Chrome\u62e1\u5f35\u30a2\u30d7\u30ea\u3092\u4f5c\u3063\u3066\u3044\u3066\u3001\u30e6\u30fc\u30b6\u306e\u30c7\u30fc\u30bf\u3092\u30e6\u30fc\u30b6\u30a2\u30ab\u30a6\u30f3\u30c8\uff08email\uff09\u5358\u4f4d\u306bCloud FireStore\u306b\u4fdd\u5b58\u3057\u305f\u3044\u3068\u601d\u3063\u3066\u3044\u307e\u3059\u3002\u30e6\u30fc\u30b6\u304c\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b\u60c5\u5831\u3092\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30eb\u30fc\u30eb<\/a>\u3092\u8a2d\u5b9a\u3057\u3066\u5236\u9650\u3057\u305f\u3044\u306e\u3067\u3001Firebase Authentication\u3067Google\u8a8d\u8a3c\u3092\u884c\u3046\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002\u7d06\u4f59\u66f2\u6298\u3042\u308a\u3001\u3044\u304f\u3064\u304b\u306e\u65b9\u6cd5\u3092\u8a66\u3057\u305f\u306e\u3067\u8a18\u9332\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n \u306a\u304a\u3001\u5358\u306bGoogle\u8a8d\u8a3c\u3057\u305f\u3044\u3060\u3051\u306a\u3089 google-api-javascript-client<\/a> \u3092\u4f7f\u3046\u306e\u304c\u4e00\u822c\u7684\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002<\/p>\n \u516c\u5f0f\u30da\u30fc\u30b8\u3067\u7d39\u4ecb\u3055\u308c\u3066\u3044\u308b\u65b9\u6cd5\u3092\u8a66\u3057\u3066\u307f\u307e\u3057\u305f\u3002\u53c2\u8003\u306b\u3057\u305f\u306e\u306f\u4ee5\u4e0b\u306e\u4e8c\u3064\u306e\u30da\u30fc\u30b8\u3067\u3059\u3002<\/p>\n \u3055\u3089\u306b\u3001 https:\/\/apis.google.com\/<\/a> \u4e0a\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u5229\u7528\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b\u305f\u3081\u3001 \u6700\u5f8c\u306b\u3001\u30dd\u30c3\u30d7\u30a2\u30c3\u30d7\u30da\u30fc\u30b8\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u3001Firebase\u3092\u521d\u671f\u5316\u3057\u3066\u8a8d\u8a3c\u51e6\u7406\u3092\u8a18\u8f09\u3057\u307e\u3059\u3002firebaseConfig\u306e\u5185\u5bb9\u306f\u3001Firebase\u30b3\u30f3\u30bd\u30fc\u30eb > \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u6982\u8981 -> \u5bfe\u8c61\u306e\u30a2\u30d7\u30ea \u306eSetting\u753b\u9762\u304b\u3089\u30b3\u30d4\u30da\u3057\u3066\u304d\u307e\u3059\u3002\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u4e0a\u306bapiKey\u304c\u9732\u51fa\u3057\u3066\u3044\u308b\u3053\u3068\u306b\u4e0d\u5b89\u3092\u611f\u3058\u307e\u3059\u304c\u3001\u3053\u3061\u3089<\/a>\u3092\u53c2\u7167\u3059\u308b\u3068\u5927\u4e08\u592b\u306a\u3088\u3046\u3067\u3059\u3002<\/p>\n typescript\u306e\u5834\u5408\u3082\u624b\u9806\u306f\u7279\u306b\u5909\u308f\u308a\u307e\u305b\u3093\u3002\u578b\u3092\u66f8\u3044\u305f\u308a\u3001\u30a2\u30ed\u30fc\u95a2\u6570\u306b\u3057\u305f\u308a\u3059\u308b\u3060\u3051\u3067\u3059\u3002<\/p>\n \u3053\u3053\u307e\u3067\u5b9f\u88c5\u3057\u305f\u3089Chrome\u62e1\u5f35\u306e\u30dd\u30c3\u30d7\u30a2\u30c3\u30d7\u30da\u30fc\u30b8\u3092\u958b\u304f\u3068\u3001Google\u8a8d\u8a3c\u753b\u9762\u304c\u3055\u3089\u306b\u30dd\u30c3\u30d7\u30a2\u30c3\u30d7\u3055\u308c\u3001user\u60c5\u5831\u3092\u53d6\u5f97\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002\u51fa\u529b\u7d50\u679c\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u611f\u3058\u3067\u3059\u3002<\/p>\n \u4e00\u898b\u826f\u3055\u305d\u3046\u306a\u306e\u3067\u3059\u304c\u3001Google\u8a8d\u8a3c\u753b\u9762\u304cWindow\u306e\u88cf\u5074\u306b\u30dd\u30c3\u30d7\u30a2\u30c3\u30d7\u3055\u308c\u3066\u6c17\u3065\u304b\u306a\u304b\u3063\u305f\u308a\u3001\u306a\u3093\u3069\u3082Chrome\u62e1\u5f35\u306e\u30a2\u30a4\u30b3\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u3001\u3044\u304f\u3064\u3082Google\u8a8d\u8a3c\u753b\u9762\u304c\u958b\u304b\u308c\u305f\u308a\u3001\u88cf\u5074\u306b\u753b\u9762\u304c\u6b8b\u3063\u3066\u3057\u307e\u3063\u305f\u308a\u3068\u3001UX\u304c\u6700\u4f4e\u3067\u3059\u3002\u3002<\/p>\n \u4e16\u306e\u4e2d\u306eChrome\u62e1\u5f35\u3092\u8272\u3005\u8a66\u3057\u3066\u3044\u308b\u3068\u3001\u30aa\u30d7\u30b7\u30e7\u30f3\u30da\u30fc\u30b8\u3067Google\u8a8d\u8a3c\u3092\u884c\u306a\u3063\u3066\u3044\u308b\u30a2\u30d7\u30ea\u3092\u767a\u898b\u3057\u307e\u3057\u305f\u3002\u305d\u3093\u306a\u306bUX\u3082\u60aa\u304f\u306a\u3044\u306e\u3067\u3001\u3084\u3063\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n \u30aa\u30d7\u30b7\u30e7\u30f3\u30da\u30fc\u30b8\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u306b\u30aa\u30d7\u30b7\u30e7\u30f3\u30da\u30fc\u30b8\u3068\u5168\u304f\u540c\u3058\u30b3\u30fc\u30c9\u3092\u7d44\u307f\u8fbc\u3093\u3067\u307f\u307e\u3057\u305f\u3002 \u8272\u3005\u8a66\u3057\u305f\u3068\u3053\u308d\u3001 \u30aa\u30d7\u30b7\u30e7\u30f3\u30da\u30fc\u30b8\u3092\u958b\u304f\u3068\u3001\u8a8d\u8a3c\u753b\u9762\u304c\u30dd\u30c3\u30d7\u30a2\u30c3\u30d7\u8868\u793a\u3055\u308c\u3001\u8a8d\u8a3c\u3092\u884c\u3046\u3053\u3068\u304c\u3067\u304d\u3057\u305f\u3002\u5225\u30bf\u30d6\u3067\u958b\u3044\u3066\u3044\u305f\u305b\u3044\u304b\u3001\u30dd\u30c3\u30d7\u30a2\u30c3\u30d7\u753b\u9762\u304c\u88cf\u306b\u96a0\u308c\u308b\u3088\u3046\u306a\u3053\u3068\u3082\u3042\u307e\u308a\u306a\u3044\u306e\u3067\u3001UX\u3082\u305d\u308c\u307b\u3069\u60aa\u304f\u306a\u3044\u3068\u611f\u3058\u307e\u3059\u3002 \u3055\u3089\u306b\u63a2\u3057\u3066\u3044\u308b\u3068\u3001 \u3053\u3053\u3067\u306f\u3001Chrome\u62e1\u5f35\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305fGoogle\u30a2\u30ab\u30a6\u30f3\u30c8\u306eaccess token\u3092chrome.identity API\u3092\u4f7f\u3063\u3066\u53d6\u5f97\u3057\u3066\u3001access token\u3092\u5143\u306bGoogle OAuth2\u8a8d\u8a3c\u3092\u884c\u3046\u3068\u3044\u3046\u9806\u756a\u3067\u51e6\u7406\u3092\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n \u307e\u305a\u3001 \u6b21\u306b\u3001\u3053\u3061\u3089<\/a>\u304b\u3089\u3001\u8a8d\u8a3c\u60c5\u5831\u3092\u4f5c\u6210 -> OAuth \u30af\u30e9\u30a4\u30a2\u30f3\u30c8ID -> Chrome \u30a2\u30d7\u30ea -> \u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3ID\u306bCHROME_EXTENSION_ID\u3092\u6307\u5b9a \u3092\u884c\u3044\u3001OAuth \u30af\u30e9\u30a4\u30a2\u30f3\u30c8ID\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n \u3055\u3089\u306b\u3001 \u3042\u3068\u306f\u3001\u8a8d\u8a3c\u51e6\u7406\u3092\u5b9f\u88c5\u3057\u307e\u3059\u3002\u30dd\u30c3\u30d7\u30a2\u30c3\u30d7\u30da\u30fc\u30b8\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u306bFirebase\u306e\u521d\u671f\u5316\u304a\u3088\u3073\u8a8d\u8a3c\u51e6\u7406\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002\u5b9f\u88c5\u306f\u3001\u3053\u3061\u3089<\/a>\u3092\u307b\u307c\u305d\u306e\u307e\u307e\u4f7f\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n \u666e\u901a\u306fFirebase\u306e\u8a8d\u8a3c\u72b6\u614b\u304c\u5909\u66f4\u3055\u308c\u305f\u3053\u3068\u3092\u691c\u77e5\u3057\u3066\u518d\u5ea6\u8a8d\u8a3c\u3057\u305f\u3044\u5834\u5408\u306f\u3001\u4ee5\u4e0b\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002 typescript\u3067\u3082\u8a18\u6cd5\u306f\u9055\u3048\u3069\u540c\u69d8\u306b\u5b9f\u88c5\u3059\u308c\u3070\u5927\u4e08\u592b\u3067\u3059\u3002<\/p>\n \u5b9f\u969b\u306e\u52d5\u304d\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n Chrome\u62e1\u5f35\u306e\u30a2\u30a4\u30b3\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u305f\u969b\u306b\u3001\u30ed\u30b0\u30a4\u30f3\u3057\u3066\u306a\u3044\u72b6\u614b\u3060\u3068 \u30ed\u30b0\u30a4\u30f3\u5f8c\u3001\u3082\u3046\u4e00\u5ea6Chrome\u62e1\u5f35\u306e\u30a2\u30a4\u30b3\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u3001\u4eca\u5ea6\u306fauth_token\u3092\u53d6\u5f97\u3067\u304d\u3066\u3001Firebase\u306eAuthentication\u306eSignIn\u3082\u3046\u307e\u304f\u3044\u3063\u3066\u3001user\u60c5\u5831\u3092\u53d6\u5f97\u3067\u304d\u307e\u3059\u3002<\/p>\n \u3061\u306a\u307f\u306b\u3001\u8a8d\u8a3c\u6e08\u307f\u306e\u5834\u5408\u306buser\u60c5\u5831\u3092\u53d6\u5f97\u3059\u308b\u307e\u3067\u306e\u30ea\u30fc\u30c9\u30bf\u30a4\u30e0\u3082\u3001 Firebase\u3068\u304b\u95a2\u4fc2\u306a\u304f\u3001Chrome\u62e1\u5f35\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305fGoogle\u30a2\u30ab\u30a6\u30f3\u30c8\u306b\u7d10\u3065\u304femail\u304c\u6b32\u3057\u3044\u3060\u3051\u306a\u3089\u3001chrome.identity<\/a> API\u3092\u4f7f\u3046\u65b9\u6cd5\u304c\u3082\u3063\u3068\u3082\u30b7\u30f3\u30d7\u30eb\u3060\u3068\u601d\u3044\u307e\u3059\u3002\u3053\u306eAPI\u306f\u3001OAuth2\u306eaccess token\u3092\u53d6\u5f97\u3059\u308b\u306e\u304c\u4e3b\u76ee\u7684\u306e\u3088\u3046\u306a\u306e\u3067\u3059\u304c\u3001access token\u3092\u53d6\u5f97\u3059\u308b\u4ee5\u5916\u306b\u3001 \u306a\u304a\u3001\u6307\u5b9a\u3067\u304d\u308bpermission\u306e\u7a2e\u985e\u306f\u3053\u3061\u3089<\/a>\u3092\u53c2\u7167\u3044\u305f\u3060\u3051\u308c\u3070\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n \u5fc5\u8981\u306a\u6a29\u9650\u304c\u8ffd\u52a0\u3055\u308c\u305f\u3053\u3068\u306f\u3001Chrome\u62e1\u5f35\u306e\u8a73\u7d30\u30da\u30fc\u30b8\u3067\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002 \u3042\u3068\u306f\u30aa\u30d7\u30b7\u30e7\u30f3\u30da\u30fc\u30b8\u3084\u30dd\u30c3\u30d7\u30a2\u30c3\u30d7\u30da\u30fc\u30b8\u3067API\u3092\u547c\u3073\u51fa\u3057\u307e\u3059\u3002<\/p>\n javascript\u3060\u3068\u3053\u308c\u3060\u3051\u3067\u3059\u3002<\/p>\n typescript\u3060\u3068\u3001\u578b\u3092\u89e3\u6c7a\u3059\u308b\u305f\u3081\u306b\u5c11\u3057\u8a18\u8ff0\u304c\u5897\u3048\u307e\u3059\u3002<\/p>\n \u578b\u5b9a\u7fa9\u3092\u8ffd\u52a0\u3057\u3066\u3001<\/p>\n \u3042\u3068\u306f\u3001\u547c\u3073\u51fa\u3059\u3060\u3051\u3067\u3059\u3002<\/p>\n \u51fa\u529b\u7d50\u679c\u306f\u3053\u3093\u306a\u611f\u3058\u3067\u3059<\/p>\n Chrome\u62e1\u5f35\u30a2\u30d7\u30ea\u3092\u4f5c\u3063\u3066\u3044\u3066\u3001\u30e6\u30fc\u30b6\u306e\u30c7\u30fc\u30bf\u3092\u30e6\u30fc\u30b6\u30a2\u30ab\u30a6\u30f3\u30c8\uff08email\uff09\u5358\u4f4d\u306bCloud FireStore\u306b\u4fdd\u5b58\u3057\u305f\u3044\u3068\u601d\u3063\u3066\u3044\u307e\u3059\u3002\u30e6\u30fc\u30b6\u304c\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b\u60c5\u5831\u3092\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30eb\u30fc\u30eb\u3092\u8a2d\u5b9a\u3057\u3066\u5236\u9650\u3057\u305f\u3044\u306e\u3067\u3001Firebase Authentication\u3067Google\u8a8d\u8a3c\u3092\u884c\u3046\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002\u7d06\u4f59\u66f2\u6298\u3042\u308a\u3001\u3044\u304f\u3064\u304b\u306e\u65b9\u6cd5\u3092\u8a66\u3057\u305f\u306e\u3067\u8a18\u9332\u3057\u3066\u304a\u304d\u307e\u3059\u3002 \u306a\u304a\u3001\u5358\u306bGoogle\u8a8d\u8a3c\u3057\u305f\u3044\u3060\u3051\u306a\u3089 google-api-javascript-client \u3092\u4f7f\u3046\u306e\u304c\u4e00\u822c\u7684\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002 \u3010\u4e0d\u63a1\u7528\u3011Firebase Authentication in \u30dd\u30c3\u30d7\u30a2\u30c3\u30d7\u30da\u30fc\u30b8 \u516c\u5f0f\u30da\u30fc\u30b8\u3067\u7d39\u4ecb\u3055\u308c\u3066\u3044\u308b\u65b9\u6cd5\u3092\u8a66\u3057\u3066\u307f\u307e\u3057\u305f\u3002\u53c2\u8003\u306b\u3057\u305f\u306e\u306f\u4ee5\u4e0b\u306e\u4e8c\u3064\u306e\u30da\u30fc\u30b8\u3067\u3059\u3002 Chrome \u62e1\u5f35\u6a5f\u80fd\u3067\u306e Firebase \u8a8d\u8a3c Firebase \u3092 JavaScript \u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306b\u8ffd\u52a0\u3059\u308b Fireb <\/span>Continue Reading<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[26,23,3,12,25],"tags":[],"_links":{"self":[{"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/posts\/259"}],"collection":[{"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/comments?post=259"}],"version-history":[{"count":1,"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/posts\/259\/revisions"}],"predecessor-version":[{"id":261,"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/posts\/259\/revisions\/261"}],"wp:attachment":[{"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/media?parent=259"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/categories?post=259"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/localhost:8000\/wp-json\/wp\/v2\/tags?post=259"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}\u3010\u4e0d\u63a1\u7528\u3011Firebase Authentication in \u30dd\u30c3\u30d7\u30a2\u30c3\u30d7\u30da\u30fc\u30b8<\/h2>\n
\n
Firebase\u5074\u306e\u8a2d\u5b9a<\/h3>\n
\n
\n
\n
\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u6982\u8981<\/code>\u30da\u30fc\u30b8\u306eWEB\u30a2\u30a4\u30b3\u30f3\u304b\u3089\u30a2\u30d7\u30ea\u3092\u767b\u9332\u3057\u307e\u3059\u3002Hosting\u306f\u4eca\u56de\u5229\u7528\u3057\u306a\u3044\u306e\u3067OFF\u306b\u3057\u307e\u3057\u305f\u3002<\/li>\n<\/ul>\n<\/li>\n
\n
\n
chrome-extension:\/\/CHROME_EXTENSION_ID<\/code>\u306e\u5f62\u5f0f\u3067\u30c9\u30e1\u30a4\u30f3\u3092\u8ffd\u52a0\u3057\u307e\u3059<\/li>\n
CHROME_EXTENSION_ID<\/code>\u306fChrome\u62e1\u5f35\u306e\u7ba1\u7406\u30da\u30fc\u30b8\u3067\u78ba\u8a8d\u3067\u304d\u307e\u3059<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n
Firebase\u306eSDK\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h3>\n
npm install firebase<\/code><\/pre>\n
manifest.json\u306e\u8a2d\u5b9a<\/h3>\n
manifest.json<\/code>\u306e
content_security_policy<\/code>\u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n
"content_security_policy": "script-src 'self' https:\/\/apis.google.com\/; object-src 'self'",<\/code><\/pre>\n
Firebase\u306e\u521d\u671f\u5316\u304a\u3088\u3073\u8a8d\u8a3c\u51e6\u7406<\/h3>\n
import * as firebase from "firebase\/app";\nimport "firebase\/auth";\n\n\/\/ Firebase\u306e\u521d\u671f\u5316\nconst firebaseConfig = {\n apiKey: "xxxxx",\n authDomain: "xxxxx.firebaseapp.com",\n databaseURL: "https:\/\/xxxxx.firebaseio.com",\n projectId: "xxxxx",\n storageBucket: "xxxxx.appspot.com",\n messagingSenderId: "xxxxx",\n appId: "xxxxx"\n};\nfirebase.initializeApp(firebaseConfig);\n\n\/\/ \u8a8d\u8a3c\u51e6\u7406\nconst provider = new firebase.auth.GoogleAuthProvider()\nprovider.addScope('https:\/\/www.googleapis.com\/auth\/userinfo.email');\nfirebase.auth().useDeviceLanguage()\nfirebase.auth().signInWithPopup(provider).then(function(result) {\n console.log('userInfo: ' + JSON.stringify(result.user))\n}).catch(function(error) {\n console.log(error)\n});<\/code><\/pre>\n
\u5b9f\u884c\u7d50\u679c<\/h3>\n
userInfo: {"uid":"xxxxx","displayName":"xxxxx","photoURL":"xxxxx","email":"xxxxx@gmail.com","emailVerified":true,"phoneNumber":xxxxx,...\u7701\u7565...}<\/code><\/pre>\n
\u3010\u4e0d\u63a1\u7528\u3011Firebase Authentication in \u30aa\u30d7\u30b7\u30e7\u30f3\u30da\u30fc\u30b8<\/h2>\n
Firebase\u5074\u306e\u8a2d\u5b9a\u3001SDK\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3001manifest.json\u306e\u8a2d\u5b9a<\/h3>\n
Firebase Authentication in \u30dd\u30c3\u30d7\u30a2\u30c3\u30d7\u30da\u30fc\u30b8<\/code>\u3068\u5168\u304f\u540c\u4e00\u3067\u3059\u3002<\/p>\n
Firebase\u306e\u521d\u671f\u5316\u304a\u3088\u3073\u8a8d\u8a3c\u51e6\u7406<\/h3>\n
\n\u3059\u308b\u3068\u3001\u65b0\u3057\u3044blank\u306e\u30bf\u30d6\u304c\u7acb\u3061\u3042\u304c\u308a\u3001\u30a2\u30c9\u30ec\u30b9\u30d0\u30fc\u306babout:blank#blocked<\/code>\u3068\u8868\u793a\u3055\u308c\u307e\u3059\u3002\u4f55\u304b\u3088\u304f\u5206\u304b\u3089\u306a\u3044\u3051\u3069\u30dd\u30c3\u30d7\u30a2\u30c3\u30d7\u30d6\u30ed\u30c3\u30af\u3055\u308c\u305f\u3088\u3046\u3067\u3059\u3002<\/p>\n
manifest.json\u306bopen_in_tab\u3092\u8ffd\u52a0<\/h3>\n
manifest.json<\/code>\u306e
"open_in_tab": true<\/code>\u3092\u6307\u5b9a\u3057\u3066\u3001\u30aa\u30d7\u30b7\u30e7\u30f3\u30da\u30fc\u30b8\u81ea\u4f53\u3092\u65b0\u3057\u3044\u30bf\u30d6\u3067\u8868\u793a\u3059\u308b\u3088\u3046\u306b\u3059\u308b\u3068\u56de\u907f\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n
"options_ui": {\n "page": "options\/options.html",\n "open_in_tab": true, \/\/ \u3053\u308c\u3092\u8ffd\u52a0\n "chrome_style": true\n },<\/code><\/pre>\n
\u5b9f\u884c\u7d50\u679c<\/h3>\n
\n\u305f\u3060\u3001\u3001\u3001\u4e00\u3064\u5927\u304d\u306a\u554f\u984c\u304c\u3042\u308a\u307e\u3059\u3002
\nopen_in_tab<\/code>\u3068\u3044\u3046\u30aa\u30d7\u30b7\u30e7\u30f3\u306f\u975e\u63a8\u5968\u3067\u3001\u3044\u305a\u308c\u524a\u9664\u3055\u308c\u3066\u3057\u307e\u3046\u4e88\u5b9a\u306a\u306e\u3067\u3059\u3002<\/b>\u5f8c\u3005\u82e6\u52b4\u3057\u305d\u3046\u306a\u306e\u3067\u3001\u5225\u306e\u65b9\u6cd5\u3092\u63a2\u3059\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n
\u3010\u63a1\u7528\u3011chrome.identity API \u3068 Firebase Authentication \u306e\u30cf\u30a4\u30d6\u30ea\u30c3\u30c9<\/h2>\n
\nFirebase Auth w\/ Google Sign-In in Chrome Extensions<\/a>
\n\u3068\u3044\u3046\u7d20\u6674\u3089\u3057\u3044\u30da\u30fc\u30b8\u3092\u767a\u898b\u3057\u307e\u3057\u305f\u3002<\/p>\nFirebase\u5074\u306e\u8a2d\u5b9a\u3001SDK\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h3>\n
Firebase Authentication in \u30dd\u30c3\u30d7\u30a2\u30c3\u30d7\u30da\u30fc\u30b8<\/code>\u306b\u66f8\u3044\u3066\u3042\u308b\u5185\u5bb9\u3068\u540c\u69d8\u306b\u3001Firebase\u5074\u306e\u8a2d\u5b9a\u3068Firebase SDK\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n
OAuth \u30af\u30e9\u30a4\u30a2\u30f3\u30c8ID\u306e\u4f5c\u6210<\/h3>\n
manifest.json\u306e\u8a2d\u5b9a<\/h3>\n
manifest.json<\/code>\u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8a18\u8ff0\u3057\u307e\u3059\u3002
client_id<\/code>\u306b\u306f\u5148\u307b\u3069\u4f5c\u6210\u3057\u305fOAuth \u30af\u30e9\u30a4\u30a2\u30f3\u30c8ID\u3092\u6307\u5b9a\u3057
scopes<\/code>\u306b
userinfo.email<\/code>\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002\u305d\u306e\u4ed6\u306e\u30b9\u30b3\u30fc\u30d7\u306f\u3053\u3061\u3089<\/a>\u3092\u53c2\u7167\u304f\u3060\u3055\u3044\u3002<\/p>\n
"permissions": [\n "identity"\n ],\n "oauth2": {\n "client_id": "xxxxxxxxxx.apps.googleusercontent.com",\n "scopes": ["https:\/\/www.googleapis.com\/auth\/userinfo.email"]\n }<\/code><\/pre>\n
Firebase\u306e\u521d\u671f\u5316\u304a\u3088\u3073\u8a8d\u8a3c\u51e6\u7406<\/h3>\n
import * as firebase from "firebase\/app";\nimport "firebase\/auth";\n\n\/\/ Firebase\u306e\u521d\u671f\u5316\nconst firebaseConfig = {\n apiKey: "xxxxx",\n authDomain: "xxxxx.firebaseapp.com",\n databaseURL: "https:\/\/xxxxx.firebaseio.com",\n projectId: "xxxxx",\n storageBucket: "xxxxx.appspot.com",\n messagingSenderId: "xxxxx",\n appId: "xxxxx"\n};\nfirebase.initializeApp(firebaseConfig);\n\n\/\/ \u8a8d\u8a3c\u51e6\u7406\nfunction startAuth(interactive: any) {\n chrome.identity.getAuthToken({interactive: !!interactive}, (token: string) => {\n if (chrome.runtime.lastError && !interactive) {\n console.log('It was not possible to get a token programmatically.');\n } else if(chrome.runtime.lastError) {\n console.error(chrome.runtime.lastError);\n } else if (token) {\n const credential = firebase.auth.GoogleAuthProvider.credential(null, token);\n firebase.auth().signInWithCredential(credential)\n .then(function(result) {\n console.log('userinfo: ' + JSON.stringify(result.user))\n })\n .catch((error: any) => {\n if (error.code === 'auth\/invalid-credential') {\n chrome.identity.removeCachedAuthToken({token: token}, function() {\n startAuth(interactive);\n });\n }\n });\n } else {\n console.error('The OAuth Token was null');\n }\n });\n}\n\nstartAuth(true);<\/code><\/pre>\n
user<\/code>\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u53d6\u5f97\u3067\u304d\u306a\u304b\u3063\u305f\u3089\u3001\u518d\u5ea6
startAuth()<\/code>\u3092\u547c\u3073\u51fa\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n
firebase.auth().onAuthStateChanged(function(user) {\n if (user) {\n console.log('userinfo: ' + JSON.stringify(user));\n } else {\n startAuth(true);\n }\n});<\/code><\/pre>\n
\u5b9f\u884c\u7d50\u679c<\/h3>\n
chrome.identity.getAuthToken()<\/code>\u3067
interactive: true<\/code>\u3092\u6307\u5b9a\u3057\u3066\u3044\u308b\u305f\u3081\u3001\u5225\u30bf\u30d6\u3067Google\u306e\u8a8d\u8a3c\u753b\u9762\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002
\n<\/p>\nuserInfo: {"uid":"xxxxx","displayName":"xxxxx","photoURL":"xxxxx","email":"xxxxx@gmail.com","emailVerified":true,"phoneNumber":xxxxx,...\u7701\u7565...}<\/code><\/pre>\n
firebase.auth().signInWithPopup<\/code>\u306b\u6bd4\u3079\u308b\u3068\u304b\u306a\u308a\u65e9\u304f\u4f53\u611f\u30670.5\u79d2\u3050\u3089\u3044\u3068\u3044\u3046\u611f\u3058\u306a\u306e\u3067\u3001user\u60c5\u5831\u3092\u3069\u3053\u304b\u306b\u30ad\u30fc\u30d7\u3057\u3066\u304a\u304f\u3088\u3046\u306a\u5de5\u592b\u304c\u3044\u3089\u306a\u3044\u306e\u3082\u3001\u3068\u3066\u3082\u52a9\u304b\u308a\u307e\u3059\u3002<\/p>\n
\u3010\u53c2\u8003\u3011chrome.identity API<\/h2>\n
getProfileUserInfo()<\/code>\u3092\u4f7f\u3063\u3066
email<\/code>\u3068
id<\/code>\u3092\u53d6\u5f97\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n
manifest.json\u306e\u8a2d\u5b9a<\/h3>\n
manifest.json<\/code>\u306b\u4ee5\u4e0b\u306epermission\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n
"permissions": [\n "identity", \/\/ chrome.identity API\u3092\u4f7f\u3046\u6a29\u9650\n "identity.email" \/\/ emai\u3092\u53d6\u5f97\u3059\u308b\u6a29\u9650\n ],<\/code><\/pre>\n
\n<\/p>\n\u30e6\u30fc\u30b6\u60c5\u5831\u53d6\u5f97\u51e6\u7406<\/h3>\n
chrome.identity.getProfileUserInfo(function(userInfo) {\n console.log('userInfo: ' + JSON.stringify(userInfo));\n});<\/code><\/pre>\n
npm install @types\/chrome<\/code><\/pre>\n
tsconfig.json<\/code>\u306b\u4ee5\u4e0b\u3092\u8ffd\u8a18\u3057\u307e\u3059\u3002<\/p>\n
"types": [\n "chrome"\n ],<\/code><\/pre>\n
chrome.identity.getProfileUserInfo((userInfo: chrome.identity.UserInfo) => {\n console.log('userInfo: ' + JSON.stringify(userInfo))\n})<\/code><\/pre>\n
\u5b9f\u884c\u7d50\u679c<\/h3>\n
userInfo: {"email":"xxxx@gmail.com","id":"xxxxxxxxxxxxxxxxx"}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"