FifaSharp
1.0.0
string ? GetOneTimeCode ( )
{
Console . Write ( "Enter the 2fa code sent to your email: " ) ;
return Console . ReadLine ( ) ;
}
void CacheCookie ( string cookie )
{
File . WriteAllText ( "cookie_cache.txt" , cookies ) ;
}
var client = new FutClient ( ) ;
bool success = await client . TryLoginAsync ( "[email protected]" , "password" , GetOneTimeCode , true , CacheCookie ) ;
Login di-cache menggunakan cookie. Setelah berhasil login satu kali dengan email dan password Anda bisa mendapatkan login cookies dengan metode GetLoginCookies
atau parameter opsional onCacheCookies
di TryLoginAsync
yang contohnya bisa Anda lihat di atas.
Setelah cookie Anda di-cache di suatu tempat, untuk masuk lagi tanpa menggunakan kata sandi atau melalui proses 2FA, cukup teruskan cookie yang Anda cache ke TryLoginAsync
.
// just a simple example of how you can use the cached login
if ( File . Exists ( "cookie_cache.txt" )
{
string cachedCookie = File . ReadAllText ( "cookie_cache.txt" ) ;
await client . TryLoginAsync ( cachedCookies ) ;
}