Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

basic authentication implementation #19

Open
melonslice opened this issue May 22, 2024 · 0 comments
Open

basic authentication implementation #19

melonslice opened this issue May 22, 2024 · 0 comments

Comments

@melonslice
Copy link

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 🙃)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant