{"id":1124,"date":"2021-02-08T16:12:51","date_gmt":"2021-02-08T08:12:51","guid":{"rendered":"https:\/\/badgameshow.com\/fly\/?p=1124"},"modified":"2021-02-08T17:30:26","modified_gmt":"2021-02-08T09:30:26","slug":"android-firebase-google%e5%b8%b3%e8%99%9f%e7%99%bb%e5%85%a5","status":"publish","type":"post","link":"https:\/\/badgameshow.com\/fly\/android-firebase-google%e5%b8%b3%e8%99%9f%e7%99%bb%e5%85%a5\/","title":{"rendered":"Android Firebase Google\u5e33\u865f\u767b\u5165"},"content":{"rendered":"<h1>Android Firebase Google\u5e33\u865f\u767b\u5165<\/h1>\n<ul>\n<li>\u6587\u7ae0\u76ee\u9304<br \/>\n<\/p>\n<ul>\n<li><a href=\"https:\/\/badgameshow.com\/fly\/android-firebase-google\u5e33\u865f\u767b\u5165\/fly\/firebase\/#a\">\u5c0e\u5165Firebase\u5c08\u6848<\/a><br \/>\n<\/li>\n<li><a href=\"https:\/\/badgameshow.com\/fly\/android-firebase-google\u5e33\u865f\u767b\u5165\/fly\/firebase\/#b\">\u65b0\u589eSHA-1\u5230Firebase<\/a><br \/>\n<\/li>\n<li><a href=\"https:\/\/badgameshow.com\/fly\/android-firebase-google\u5e33\u865f\u767b\u5165\/fly\/firebase\/#c\">\u5c0e\u5165Google Login<\/a><br \/>\n<\/li>\n<li><a href=\"https:\/\/badgameshow.com\/fly\/android-firebase-google\u5e33\u865f\u767b\u5165\/fly\/firebase\/#d\">Google Login<\/a><br \/>\n<\/li>\n<li><a href=\"https:\/\/badgameshow.com\/fly\/android-firebase-google\u5e33\u865f\u767b\u5165\/fly\/firebase\/#e\">Google Login Callback(\u4fe1\u7bb1,\u5927\u982d\u7167,\u540d\u7a31)<\/a><br \/>\n<\/li>\n<li><a href=\"https:\/\/badgameshow.com\/fly\/android-firebase-google\u5e33\u865f\u767b\u5165\/fly\/firebase\/#f\">\u767b\u51faGoogle\u5e33\u865f<\/a><br \/>\n<\/li>\n<li><a href=\"https:\/\/badgameshow.com\/fly\/android-firebase-google\u5e33\u865f\u767b\u5165\/fly\/firebase\/#g\">\u53d6\u5f97\u4e0a\u6b21\u767b\u5165\u7684Google\u5e33\u865f<\/a><br \/>\n<\/li>\n<li><a href=\"https:\/\/badgameshow.com\/fly\/android-firebase-google\u5e33\u865f\u767b\u5165\/fly\/firebase\/#h\">\u6548\u679c\u5c55\u793a<\/a><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2><\/h2>\n<p><a id=\"a\"><\/a><\/p>\n<h4>1.\u5c0e\u5165Firebase\u5c08\u6848<\/h4>\n<p>https:\/\/badgameshow.com\/fly\/firebase-authentication\/fly\/firebase\/<\/p>\n<p><a id=\"b\"><\/a><\/p>\n<h4>2.\u65b0\u589eSHA-1\u5230Firebase<\/h4>\n<h4>\u5c08\u6848\u8a2d\u5b9a>SHA \u6191\u8b49\u6307\u7d0b>\u65b0\u589e\u6307\u7d0b<\/h4>\n<h4>\u53d6\u5f97\u6307\u7d0bsigingReport<\/h4>\n<p><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/badgameshow.com\/fly\/wp-content\/uploads\/2021\/02\/wp_editor_md_fb7416e781bcb7cb9b44191a540f1e2a.jpg\"><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/fly\/wp-content\/uploads\/2021\/02\/wp_editor_md_fb7416e781bcb7cb9b44191a540f1e2a.jpg\" alt=\"\" \/><\/a><\/p>\n<p><a id=\"c\"><\/a><\/p>\n<h4>3.\u5c0e\u5165Google Login<\/h4>\n<pre><code class=\"language-Gradle line-numbers\">implementation 'com.google.android.gms:play-services-auth:19.0.0'\n<\/code><\/pre>\n<p><a id=\"d\"><\/a><\/p>\n<h4>4.Google Login<\/h4>\n<pre><code class=\"language-Kotlin line-numbers\">private val GOOGLE_SIGN_IN_REQUEST = 40\n\nval gso = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)\n    .requestIdToken(getString(R.string.default_web_client_id))\n    .requestEmail()\n    .build()\n\nval client = GoogleSignIn.getClient(requireContext(), gso)\nstartActivityForResult(client.signInIntent, GOOGLE_SIGN_IN_REQUEST)\n<\/code><\/pre>\n<p><a id=\"e\"><\/a><\/p>\n<h4>5.Google Login Callback(\u4fe1\u7bb1,\u5927\u982d\u7167,\u540d\u7a31)<\/h4>\n<pre><code class=\"language-Kotlin line-numbers\">override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {\n    super.onActivityResult(requestCode, resultCode, data)\n\n    if (requestCode == GOOGLE_SIGN_IN_REQUEST &amp;&amp; resultCode == RESULT_OK) {\n        \/\/\u7372\u53d6\u5e33\u6236\n        val account = GoogleSignIn.getSignedInAccountFromIntent(data).getResult(ApiException::class.java)\n\n        \/\/\u4fe1\u7bb1\n        val email = account.email\n        \/\/\u540d\u7a31\n        val displayName = acccount.displayName\n        \/\/\u5927\u982d\u7167\n        val photoUrl = account.photoUrl\n        val credential = GoogleAuthProvider.getCredential(account?.idToken, null)\n\n        \/\/\u5c07\u8cc7\u6599\u9001\u7d66Firebase\u7d00\u9304\n        FirebaseAuth.getInstance()\n            .signInWithCredential(credential)\n    }\n}\n<\/code><\/pre>\n<p><a id=\"f\"><\/a><\/p>\n<h4>6.\u767b\u51faGoogle\u5e33\u865f<\/h4>\n<pre><code class=\"language-Kotlin line-numbers\">val gso = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)\n            .requestIdToken(getString(R.string.default_web_client_id))\n            .requestEmail()\n            .build()\n\nval client = GoogleSignIn.getClient(requireContext(), gso)\nclient.signOut()\n<\/code><\/pre>\n<p><a id=\"g\"><\/a><\/p>\n<h4>7.\u53d6\u5f97\u4e0a\u6b21\u767b\u5165\u7684Google\u5e33\u865f<\/h4>\n<pre><code class=\"language-Kotlin line-numbers\">GoogleSignIn.getLastSignedInAccount(this)\n<\/code><\/pre>\n<p><a id=\"h\"><\/a><\/p>\n<h4>8.\u6548\u679c\u5c55\u793a<\/h4>\n<p><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/badgameshow.com\/fly\/wp-content\/uploads\/2021\/02\/20210208_160315.gif\"><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/fly\/wp-content\/uploads\/2021\/02\/20210208_160315-138x300.gif\" alt=\"\" \/><\/a><\/p>\n\n<div style=\"font-size: 0px; height: 0px; line-height: 0px; margin: 0; padding: 0; clear: both;\"><\/div>","protected":false},"excerpt":{"rendered":"<p>Android Firebase Google\u5e33\u865f\u767b\u5165 \u6587\u7ae0\u76ee\u9304 \u5c0e\u5165Firebase\u5c08\u6848 \u65b0\u589eSHA-1\u5230F &hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"pgc_sgb_lightbox_settings":"","footnotes":""},"categories":[34],"tags":[13,40,171],"class_list":["post-1124","post","type-post","status-publish","format-standard","hentry","category-firebase","tag-android","tag-firebase","tag-google"],"_links":{"self":[{"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/posts\/1124","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/comments?post=1124"}],"version-history":[{"count":4,"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/posts\/1124\/revisions"}],"predecessor-version":[{"id":1130,"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/posts\/1124\/revisions\/1130"}],"wp:attachment":[{"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/media?parent=1124"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/categories?post=1124"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/tags?post=1124"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}