Cant configure Google Auth , i use Flutter+Node without Firebase

Im trying to resolve a problem with Google Auth.

When i Sign In its working fine , i generate id,username,email etc and then i try to authenticate the user so it generates the accessToken(for some reason not the idToken,this token is null).

Then i send the token in my backend and i try to decrypt it … but with no luck .

I already setup a keygen for my android app and pass the sha1 in the google.cloud.console , i enable the people api and i added some scopes but still i get this error :

Error: Wrong number of segments in token: (here is a large token,nearly 216 characters)

Here is my flutter code :

// ignore_for_file: avoid_print
import 'dart:async';
import 'dart:convert';
import 'package:flutter/material.dart';
//.envs
import 'package:flutter_dotenv/flutter_dotenv.dart';
//Libs
import 'package:google_sign_in/google_sign_in.dart';
import 'package:http/http.dart' as http;

GoogleSignIn _googleSignIn = GoogleSignIn(
  //clientId: 'your-client_id.apps.googleusercontent.com',
  scopes: scopes,
);
const List<String> scopes = <String>['openid'];

class Google_Auth extends StatefulWidget {
  const Google_Auth({super.key});

  @override
  State createState() => _Google_AuthState();
}

class _Google_AuthState extends State<Google_Auth> {
  bool _isAuthorized = false;
  GoogleSignInAccount? _currentUser;
  Map<String, dynamic>? _userJson;
  @override
  void initState() {
    super.initState();

    _googleSignIn.onCurrentUserChanged
        .listen((GoogleSignInAccount? account) async {
      _isAuthorized = account != null;

      setState(() {
        _currentUser = account;
        if (_currentUser != null) {
          _userJson = {
            'displayName': _currentUser!.displayName,
            'email': _currentUser!.email,
            'id': _currentUser!.id,
            'photoUrl': _currentUser!.photoUrl,
          };
          print(_userJson);
        } else {
          _userJson = null;
        }
      });
    });
    _googleSignIn.signInSilently();
  }

  //Send User Data to Backend
  Future<void> send_Auth(String? token) async {
    try {
      if (token == null) {
        ScaffoldMessenger.of(context).showSnackBar(
          SnackBar(
            content: Text('Failed to sign in with Google (token is null)'),
          ),
        );
        return;
      }
      final response = await http.post(
        Uri.parse('${dotenv.env['baseUrl']}/auth_google'),
        headers: <String, String>{
          'Content-Type': 'application/json; charset=UTF-8',
        },
        body: jsonEncode(<String, String>{
          'idToken': token,
        }),
      );
      if (response.statusCode == 200) {
        final Map<String, dynamic> user = jsonDecode(response.body);
        ScaffoldMessenger.of(context).showSnackBar(
          SnackBar(
            content: Text('Sign in successful! Welcome ${user['name']}'),
          ),
        );
      } else {
        ScaffoldMessenger.of(context).showSnackBar(
          SnackBar(
            content: Text('Failed to sign in with Google'),
          ),
        );
      }
    } catch (error) {
      print(error);
    }
  }

  //Auth Scopes
  Future<void> _handleAuthorizeScopes() async {
    final bool isAuthorized = await _googleSignIn.requestScopes(scopes);
    setState(() {
      _isAuthorized = isAuthorized;
    });
  }

  //Handle Sign In - Sign Out
  Future<void> _handleSignIn() async {
    try {
      GoogleSignInAccount? account = await _googleSignIn.signIn();
      if (account == null) {
        return null;
      }
      final googleSignInAuthentication = await account.authentication;
      print(googleSignInAuthentication.accessToken);
      print(googleSignInAuthentication.idToken);
      send_Auth(googleSignInAuthentication.accessToken);
    } catch (error) {
      print(error);
    }
  }

  Future<void> _handleSignOut() async {
    await _googleSignIn.disconnect();
    setState(() {
      _currentUser = null;
      _userJson = null;
    });
  }

  Widget _buildBody() {
    final GoogleSignInAccount? user = _currentUser;
    if (user != null) {
      return Column(
        mainAxisAlignment: MainAxisAlignment.spaceAround,
        children: <Widget>[
          ListTile(
            leading: GoogleUserCircleAvatar(
              identity: user,
            ),
            title: Text(user.displayName ?? ''),
            subtitle: Text(user.email),
          ),
          const Text('Signed in successfully.'),
          if (!_isAuthorized) ...<Widget>[
            const Text('Additional permissions needed to read your contacts.'),
            ElevatedButton(
              onPressed: _handleAuthorizeScopes,
              child: const Text('REQUEST PERMISSIONS'),
            ),
          ],
          ElevatedButton(
            onPressed: _handleSignOut,
            child: const Text('SIGN OUT'),
          ),
        ],
      );
    } else {
      return Column(
        mainAxisAlignment: MainAxisAlignment.spaceAround,
        children: <Widget>[
          const Text('You are not currently signed in.'),
          ElevatedButton(
            onPressed: _handleSignIn,
            child: Text('Press here'),
          )
        ],
      );
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Google Sign In'),
      ),
      body: ConstrainedBox(
        constraints: const BoxConstraints.expand(),
        child: _buildBody(),
      ),
    );
  }
}

And my node Server :

const { JWT } = require('google-auth-library');

const logIn_Controller = {
async verify(token) {
    try {
      const client = new JWT(process.env.GOOGLE_AUTH_TOKEN);
      const ticket = await client.verifyIdToken({
        idToken: token,
        audience: process.env.GOOGLE_AUTH_TOKEN,
      });
      const payload = ticket.getPayload();
      return payload;
    } catch (error) {
      console.log(error);
    }
  },

  //Google Auth
  async auth_google(req, res) {
    try {
      const token = req.body.idToken;
      console.log(token);
      const payload = await logIn_Controller.verify(token);
      console.log(payload);
      res.status(200).json(payload);
    } catch (error) {
      console.log(error);
      res.status(401).json({ error: 'Invalid token' });
    }
  },
module.exports = logIn_Controller;

This is the command i used for the keygen to be generated :

keytool -genkey -v -keystore mykey.jks -keyalg RSA -keysize 2048 -validity 10000 -alias androiddebugkey

I pass it in app folder and i configure build.grandle like this :

 debug{
            keyAlias 'androiddebugkey'
            keyPassword 'mycode'
            storeFile file('../app/mykey.jks')
            storePassword 'mycode'
        }

So what i am missing ?

Also do i really need that key?
I mean i already sign in my app when i release it so maybe this is not needed?

Thanks in Advance.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật