'How to add the Firebase configuration to the API requests that I make?

I'm attempting to create my own dart package for firebase. I need something that is lightweight and does not require to setup an SDK(its to complicated form me).

My Library File(burrito.dart(a Wraper))

import 'dart:convert';
import 'package:sexy_api_client/sexy_api_client.dart';

//Types / classes
class FirebaseToken{
  FirebaseToken({
    required this.idToken,
    required this.email,
    required this.refreshToken,
    required this.expiresIn,
    required  this.localId,
  });
  ///A Firebase Auth ID token for the newly created user.
  final String idToken;
  ///The email for the newly created user.
  final String email;
  ///A Firebase Auth refresh token for the newly created user.
  final String refreshToken;
  ///The number of seconds in which the ID token expires.
  final int expiresIn;
  ///The uid of the newly created user.
  final String localId;
  static FirebaseToken parse(String json){
    Map<String,dynamic> parsedJSON = jsonDecode(json);
    return FirebaseToken(
      idToken: parsedJSON["idToken"], 
      email: parsedJSON["email"], 
      refreshToken: parsedJSON["refreshToken"], 
      expiresIn: int.parse(parsedJSON["expiresIn"]), 
      localId: parsedJSON["localId"],
    );
  }
}

//Local functions

//Firebase and all of its methods
class Firebase{
  Firebase({
    required this.apiKey,
  });
  final String apiKey;
  /*Don't  add them unless absolutely necessary
  final String authDomain;
  final String projectId;
  final String storageBucket;
  final String messagingSenderId;
  final String appId;
  final String measurementId;
  */
  Future<String> signUpWithEmail({
    ///The email for the user to create.
    required String email,
    ///The password for the user to create.
    required String password,
  })async{
    Map<String,dynamic> parameters = {
      "email" : email,
      "password" : password,
      ///Whether or not to return an ID and refresh token. Should always be true.
      "returnSecureToken" : true,
    };
    String response = await SexyAPI(
      url: "https://identitytoolkit.googleapis.com",
      path: "/v1/accounts:signUp",
      parameters: {
        "key" : apiKey,
      },
    ).post(
      headers: {
        "Content-Type" : "application/json",
      },
      body: jsonEncode(parameters),
    );
    return response;
  }
}

My test


import 'package:burrito/burrito.dart';
import 'package:test/test.dart';

void main() {
  Firebase firebase = Firebase(apiKey: "myAPIKey");
  test("Sign up with email", ()async{
    String firebaseToken = await firebase.signUpWithEmail(
      email: "[email protected]", 
      password: "myPassword",
    );
    print(firebaseToken);
  });
}

Test output

enter image description here

Where do I place the configuration below on the request

enter image description here I'm following this docs

I appreciate the time you've taken to help me☺️



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source