How to send request to another server in shelf dart


I need to make a request to my firebase rtdb from my shelf server hosted on, I have the url and the db secrets. But whenever i try to make a get request to the db url using the http package, i get a 401 error.

My code:

import 'dart:io';
import 'package:http/http.dart';
import 'package:firebase/firebase_io.dart';

class FirebaseLocalClient {
  void putSudokuBoard() async {
    var a = await get(
            "<db url>"),
        headers: {
          "Authorization": "Bearer <your database secret>",
          'Content-Type': "application/js"


void main(List<String> args) {

I call this code from a shelf server(similar to the code in main function), but running it here itself recieves a 401 error.
I am not able to understand why i am recieving a 401 error, i have the db secrets and yet i am unable to get the data at that location. I tried using the admin sdk json but recieved 401 on that too

The output when i use a.body:
enter image description here

The output when i use a.statuscode:
enter image description here


If you are using the db secrets, it looks like you need to append the auth param.

curl ''

Remove the Authorization header and try it in curl

Answered By – aaronvargas

Answer Checked By – Pedro (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *