簡體   English   中英

Google OAuth 2.0 失敗並出現錯誤 400:某些 client_id 的無效請求,無法登錄,因為“App”發送了無效請求

[英]Google OAuth 2.0 failing with Error 400: invalid_request for some client_id, Can't Sign in because 'App' sent an invalid request

我有一個 Flutter 應用程序,它使用googleapis_auth 1.3.1googleapis 9.2.0 我做了什么:

  • 啟用谷歌日歷 API
  • 將 Flutter 項目連接到 Firebase 並使用基本模板進行設置。

但我收到以下錯誤: 在此處輸入圖像描述

這是我的代碼:

`
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:googleapis/calendar/v3.dart' as cal;
import 'package:url_launcher/url_launcher.dart';
import 'gCalender/calendar_client.dart';
import 'secert.dart';
import 'package:googleapis_auth/auth_io.dart';

void main() async {
  //firebase initialize
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();
  //google apis init
  var clientID =  ClientId(Secret.getId(),"");
  var scopes = [cal.CalendarApi.calendarEventsScope];
  await clientViaUserConsent(clientID, scopes, prompt).then((AuthClient client) async {
    CalendarClient.calendar = cal.CalendarApi(client);
  });

  
  runApp(const MyApp());
}
void prompt(String url) async {
    if (!await launchUrl(Uri.parse(url))) {
      throw 'Could not launch $url';
    }
}
class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Social Login',
      theme: theme(),
      debugShowCheckedModeBanner: false,
      initialRoute: SplashScreen.routeName,
      // home: const SplashScreen(),
      routes: routes,
    );
  }
}
`

我瀏覽了 inte.net 但找不到任何解決方案。

如果您使用模擬器,請在真實手機中嘗試該應用程序,因為有時 firebase 服務在虛擬手機中無法正常運行

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM