ArunPrakashG / valorant_client

Unofficial valorant client to interact with riot's valorant game api.
MIT License
6 stars 2 forks source link

2FA : Mutlifactor Authentication feature ? #4

Open waajito opened 2 years ago

waajito commented 2 years ago

Hey I've been using your package and it's amazing. but the only problem I've faced is accounts with 2FA.

So is there any way were can implement riot's RSO and combine it with the client.

You've mentioned about RSO. But am unable to find anymore details about how to implement it.

yagizdo commented 2 years ago

I agree, I also love using the client. But it's a pity that there is no 2fa account support :/

ArunPrakashG commented 2 years ago

Hi there, sorry for late reply, got caught up with work.

At the moment, I am not really getting time to invest in this library. I can't provide any guarantee at the moment but I will try to research on implementing 2FA support in the package.

Edit: Adding Reference document for future. https://github.com/Soneliem/Useful-ValorantAPI-Info/blob/main/snippets/2FA.md

ArunPrakashG commented 2 years ago

Hi there @bharadwajpalakurthy ! I have worked on the 2FA support according to the reference document added on previous comment. It's available on a separate branch, feel free to test it out.

NOTE: I have not tested it yet, will be doing it in coming days.

Branch - https://github.com/ArunPrakashG/valorant_client/tree/feature/2fa

ValorantClient client = ValorantClient(
    UserDetails(
      userName: json['username'],
      password: json['password'],
      region: Region.eu, // Available regions: na, eu, ap, ko
    ),
    persistSession: false,
    enableDebugLog: true,
    callback: Callback(
      onError: (String error) {
        print(error);
      },
      onRequestError: (DioError error) {
        print(error.message);
      },
    ),
    authCodeCallback: () async {
      print('Please enter the auth code:');
      return null;
    },
  );

To use this, you need to use authCodeCallback property in the ValorantClient instance. It is an async callback. i.e., it will wait until the callback is fully executed.

How to use this? You can display a dialog or navigate the user to a different page from this callback asynchronously, and then return the code typed in by the user from the method.

ArunPrakashG commented 2 years ago

@yagizdo do check out the above comment. might be helpful for you as well!

yagizdo commented 2 years ago

@ArunPrakashG Thank you! I will try as soon as possible. But when that person comes, I need to show the screen etc. :D I am using Provider so I cannot send the user directly to another page :/

ArunPrakashG commented 2 years ago

@yagizdo I think you could display a dialog with text input for the code.

yagizdo commented 2 years ago

@ArunPrakashG Thank you I will try

yagizdo commented 2 years ago

I have tested. The dialog is displayed, but as I understand it, it fires as it tries to log in without waiting for a response from the dialog. If there is a 2fa code, it should continue after waiting and receiving it.

At least that's my opinion from what I've tested

For example, I say wait for the dialog to open, but I couldn't see a place where I can send the incoming auth code. I'm thinking if I need to take the code from the user and export it somewhere for the API request

Screen Shot 2022-06-21 at 00 06 05

ArunPrakashG commented 2 years ago

@yagizdo You can display the dialog async from the callback method.

authCodeCallback: () async {
      print('Please enter the auth code:');
// display dialog here, get result and return the string
    final result = await showDialog(...);
      return result;
    },

this way, it will wait till the dialog is closed and then return the value.

If possible, can you show me the code where the dialog is shown so I can further boil it down on the cause.

yagizdo commented 2 years ago

I will try again based on what you said. If I have a problem again, I will share it with the code.

thank you!

yagizdo commented 1 year ago

Sorry, I was a little busy, I couldn't try it. Are there any updates?