flutter在没有Firebase的android中使用Google登录

There seems to be missing a guide for Google sign in with flutter, without firebase. Guides for firebase are in abundance, but if for any reason you want to go bare with google sign in, you are on your own.

似乎缺少有关在没有Firebase的情况下进行Google登录的指南。 Firebase的指南很多,但是如果您出于任何原因想要使用Google登录,那么您就自己一个人。

So let’s discover what is necessary for Google sign in with flutter;Most of it is also relevant for any other framework (Android native, react-native etc’).

因此,让我们发现使用flutter登录Google的必要条件;其中大多数也与任何其他框架(Android本机,react-native等)相关。

Our steps are:- Generate signed key for your android app- Registering the app in Google cloud services- Using google_sign_in package to sign in with google

我们的步骤是:-为您的android应用生成签名密钥-在Google云服务中注册该应用-使用google_sign_in程序包与google登录

必要的认证背景 (Necessary authentication background)

Google sign in is using oAuth 2.0 protocol, which in turn use various ways of authentication depending on the platform.

Google登录使用oAuth 2.0协议,该协议又会根据平台使用各种身份验证方式。

The details themselves are interesting but not relevant for you now, all you need to know is that in mobile the method is using some secure signature of the app to allow you to make requests.

详细信息本身很有趣,但现在与您无关。您需要知道的是,在移动设备中,该方法使用应用程序的一些安全签名来允许您发出请求。

Should you want to use the same google sign in with web application or server-to-server the communications way will be different. Server-to-server for example is more reliant on secret key passing, as you are in a “safe” environment and not running on a customer client.

如果您想在Web应用程序或服务器到服务器中使用相同的google登录,则通信方式会有所不同。 例如,服务器到服务器更依赖于密钥传递,因为您处于“安全”环境中并且不在客户客户端上运行。

What that means for you, is that in order to start using Google sign in with your android application, you need to sign it. Something you’d need to do anyway if you wish to release it to the playstore, but now is a good place to start.

这对您意味着什么,为了开始使用Google在Android应用程序中登录,您需要对其进行签名。 如果您希望将其发布到Playstore,则仍然需要执行某些操作,但是现在是一个不错的起点。

为您的Android应用生成签名密钥 (Generate signed key for your android app)

When generating signed key for android, there are 2 “channels” in the build that use the signed key: debug

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在 Flutter 使用 Firebase 集成苹果登录,需要完成以下步骤: 1. 在 Firebase 控制台创建一个新的项目,并将应用程序与该项目相关联。 2. 在 Firebase 控制台启用苹果登录,并配置应用程序的 Bundle ID 和 Team ID。 3. 在 Xcode 为应用程序配置 Sign In with Apple 并创建一个新的 App ID。 4. 在 Firebase 控制台下载并添加苹果开发证书和密钥。 5. 在 Flutter 项目添加 Firebase 和 Sign In with Apple 插件。 6. 在 Flutter 代码使用 Firebase 提供的相应 API 实现苹果登录流程。 以下是一个示例代码片段,演示如何使用 Firebase 实现苹果登录: ``` import 'package:flutter/material.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:flutter_signin_button/flutter_signin_button.dart'; class AppleSignInPage extends StatefulWidget { @override _AppleSignInPageState createState() => _AppleSignInPageState(); } class _AppleSignInPageState extends State<AppleSignInPage> { final FirebaseAuth _auth = FirebaseAuth.instance; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text("Sign In with Apple"), ), body: Center( child: SignInButton( Buttons.Apple, onPressed: () async { await Firebase.initializeApp(); final AuthCredential credential = await SignInWithApple.getAppleIDCredential( scopes: <String>[ 'email', 'name', ], ); final UserCredential userCredential = await _auth.signInWithCredential(credential); final User user = userCredential.user; ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text("Sign In with Apple succeeded for ${user.uid}"), ), ); }, ), ), ); } } ``` 注意:需要在 Info.plist 文件添加 Sign In with Apple 的 URL scheme,以便应用程序可以处理 Sign In with Apple 的回调。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值