~ruther/NosTale-Gfless

ref: fc51a68e949a505ac95fe9b5e7363245d2b539d8 NosTale-Gfless/NosTaleGfless/GameforgeAuthenticator.cs -rw-r--r-- 1.1 KiB
fc51a68e — František Boháček Initial commit 4 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using NostaleAuth.Api;
using NostaleAuth.Models;

namespace NosTaleGfless
{
    public class GameforgeAuthenticator
    {
        public GameforgeAuthenticator(GameforgeApi api = null, Locales locale = null, Guid? installationId = null)
        {
            Api = api ?? new GameforgeApi();
            InstallationId = installationId;
            Locale = locale ?? Locales.Germany;
        }
        
        public Guid? InstallationId { get; set; }
        
        public Locales Locale { get; set; }
        
        public GameforgeApi Api { get; }
        
        public async Task<GameforgeLauncher> Authenticate(string email, string password)
        {
            Guid installationId = InstallationId ?? Api.GenerateIntallationId(email, password);
            AuthorizedGameforgeApi authorizedGameforgeApi = await Api.Login(email, password, Locale, installationId);

            IEnumerable<GameforgeAccount> accounts = await authorizedGameforgeApi.GetAccounts();
            
            return new GameforgeLauncher(authorizedGameforgeApi, accounts, email);
        }
    }
}
Do not follow this link