Esempio n. 1
0
 /// <inheritdoc />
 public BedrockServerType(Alex game, XboxAuthService xboxAuthService) : base(new BedrockServerQueryProvider(game), "Bedrock", "bedrock")
 {
     DefaultPort     = 19132;
     Alex            = game;
     ProtocolVersion = McpeProtocolInfo.ProtocolVersion;
     XboxAuthService = xboxAuthService;
 }
Esempio n. 2
0
        private void OnLoginButtonPressed()
        {
            //      Log.Info("Login initiated...");

            LoginButton.Enabled = false;

            var profileManager = GetService <ProfileManager>();

            XboxAuthService.OpenBrowser(ConnectResponse.verification_uri);

            if (Clipboard.IsClipboardAvailable())
            {
                try
                {
                    Clipboard.SetText(ConnectResponse.user_code);
                }
                catch (Exception ex)
                {
                    Log.Warn(ex, $"Could not set keyboard contents!");
                }
            }

            //   Log.Info($"Browser opened...");
            AuthenticationService.DoDeviceCodeLogin(GetService <ResourceManager>().DeviceID, ConnectResponse.device_code, CancellationToken.Token).ContinueWith(
                (task) =>
            {
                try
                {
                    var result = task.Result;
                    if (result.success)
                    {
                        var r = AuthenticationService.DecodedChain.Chain.FirstOrDefault(x =>
                                                                                        x.ExtraData != null && !string.IsNullOrWhiteSpace(x.ExtraData.Xuid));

                        var profile = new PlayerProfile(r.ExtraData.Xuid, r.ExtraData.DisplayName,
                                                        r.ExtraData.DisplayName,
                                                        new Skin()
                        {
                            Slim    = true,
                            Texture = null
                        }, result.token.AccessToken,
                                                        JsonConvert.SerializeObject(result.token),
                                                        "xbox");

                        profileManager.CreateOrUpdateProfile("xbox", profile, true);
                        Ready?.Invoke(profile);

                        //Log.Info($"Continuewith Success!");
                    }
                    else
                    {
                        //Log.Info($"Continuewith fail!");
                    }
                }
                catch (Exception ex)
                {
                    Log.Warn($"Authentication issue: {ex.ToString()}");
                }
            });
        }
Esempio n. 3
0
        private static async void Test()
        {
            XboxAuthService authService = new XboxAuthService();
            var             authConnect = await authService.StartDeviceAuthConnect();

            Console.WriteLine($"Code: {authConnect.user_code}");

            XboxAuthService.OpenBrowser(authConnect.verification_uri);

            await authService.DoDeviceCodeLogin(Guid.NewGuid().ToString(), authConnect.device_code, CancellationToken.None);
        }
Esempio n. 4
0
        public BedrockLoginState(GuiPanoramaSkyBox skyBox, Action <PlayerProfile> readyAction, XboxAuthService xboxAuthService)
        {
            Title = "Bedrock Login";
            AuthenticationService = xboxAuthService;
            _backgroundSkyBox     = skyBox;
            Background            = new GuiTexture2D(_backgroundSkyBox, TextureRepeatMode.Stretch);
            BackgroundOverlay     = Color.Transparent;
            Ready = readyAction;

            CanUseClipboard = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);

            ConnectResponse = AuthenticationService.StartDeviceAuthConnect().Result;

            Initialize();
        }
Esempio n. 5
0
        public BedrockLoginState(GuiPanoramaSkyBox skyBox, Action <PlayerProfile> readyAction, XboxAuthService xboxAuthService)
        {
            Title = "Bedrock Login";
            AuthenticationService = xboxAuthService;
            _backgroundSkyBox     = skyBox;
            Background            = new GuiTexture2D(_backgroundSkyBox, TextureRepeatMode.Stretch);
            BackgroundOverlay     = Color.Transparent;
            Ready = readyAction;

            _authCodeElement = new GuiTextElement()
            {
                TextColor = TextColor.Cyan,
                Text      = "Please wait...\nStarting authentication process...",
                FontStyle = FontStyle.Italic,
                Scale     = 1.1f
            };

            CanUseClipboard = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);

            Initialize();
        }