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

Do not directly depend on QRCoder library #7

Open
natenho opened this issue Oct 1, 2019 · 1 comment
Open

Do not directly depend on QRCoder library #7

natenho opened this issue Oct 1, 2019 · 1 comment

Comments

@natenho
Copy link

natenho commented Oct 1, 2019

The library is directly dependant on "QRCoder" nuget package, so the clients are locked in to this library to authenticate. A good way to avoid this is to defer QR code generation through a delegate that should be implemented by the client code, something like:

public async Task AutenticateWithQrCodeAsync(Action<Guid> printQrCode)
{
	if (string.IsNullOrEmpty(_authToken))
	{
		await GetTokenAsync();
	}
	
	printQrCode(_qrCodeId); // Calls the action passed by the caller (in the example program it could be the GetQrCodeAsAscii stuff);

	var payload = new
	{
		qr_code_id = _qrCodeId,
		type = "login-webapp"
	};

	while (!IsAuthenticated()) // Could have an attempt limit
	{
		var response = await _client.PostAsync<Dictionary<string, object>>(_endpoints.Lift, payload, GetHeaders());
                if(Succeeded(response))
                {
                       break;
                }

	        await Task.Delay(2000);              
	}

	FillTokens(response);

	FillAutenticatedUrls(response);
}
@natenho natenho mentioned this issue Oct 1, 2019
@lira92
Copy link
Owner

lira92 commented Oct 1, 2019

@natenho I will think about it, but I am worry about to difficult the usage of package, maybe we can keep the core of library without QRCode dependency (using something like you propose) and create another package with an extension for generate QRCode to make the usage simple. This way if clients wants to avoid lock with QRCode library they use core package, but if they aren't worry about it, they can use directly the extension package.

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