Beispiel #1
0
        internal MastodonConnection(string instanceUri, IFunctionContainer functionContainer)
        {
            this.InstanceUri = instanceUri;
            this.Auth        = MastodonAuthenticationHouse.Get(this.InstanceUri);
            this.container   = functionContainer;

            if (!this.Auth.HasAuthenticated)
            {
                // 認証完了した時の処理
                this.Auth.Completed += (sender, e) =>
                {
                    this.ImportAuthenticationData();
                    Task.Run(async() =>
                    {
                        await this.StartFunctionAsync();
                    }).Wait();
                };

                // 認証開始
                this.Auth.StartOAuthLogin();
            }
            else
            {
                this.ImportAuthenticationData();
                this.StartFunctionAsync();
            }
        }
Beispiel #2
0
        private async void InitializeAsync(OAuthAccessTokenRepository tokenRepo)
        {
            this.Auth = await MastodonAuthenticationHouse.Get(this.InstanceUri, tokenRepo);

            while (!this.Auth.HasAuthenticated)
            {
                await this.Auth.DoAuth(tokenRepo);

                // TODO AccessToken が無効になってた場合にのみここに来るはず。
                // AccessToken をクリアして、WebView で OAuth 認証からやり直す必要あり。
            }

            this.ImportAuthenticationData();
            await this.StartFunctionAsync();
        }