Skip to content

basic authentication implementation #19

Description

@melonslice

Hi salihagic :)

thank you verry much for the work you have done with this Project. You are such a bless :) 👍

In my Case I have a API with basic Authentication. As i refer, there is no common Way to set this up in the existing Class. So i done it this way before init()

  String username = 'username';
  String password = 'password';
  String basicAuth =
      'Basic ${base64.encode(utf8.encode('$username:$password'))}';
  print(basicAuth);

  restApiClient.addOrUpdateHeader(key: 'authorization', value: basicAuth);
  
  //init must be called, preferably right after the instantiation
  await restApiClient.init();

The function to modify the Header i found in your Library :) And it works :)
I don´t know if it is necessary to do the formatingstuff of the String, but i found it on the Internet and it works, so i don´t touche it :)

If you like you can use my code and implement the Basic Authentication in your Library. Perhabs there is an other better Way to do this (i am coding dart since two days 🙃)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions