Exemple #1
0
        protected override async Task <AuthToken?> GetFirstToken(string callbackUri)
        {
            var code = GetQueryParam("code");

            if (code is null)
            {
                return(null);
            }

            // The code is used as proof of identity from here on out
            await SetWorkflow(new AuthWorkflow { State = code, Type = AuthWorkflowType.AuthCode });

            var result = await Request(
                "register",
                new AuthCodeAndCallbackUri { Code = code, CallbackUri = callbackUri });

            if (!string.IsNullOrEmpty(result.Error))
            {
                return(null);
            }

            var token = new AuthToken(result.Token.ExpiresInSec, result.Token.AccessToken);

            await SetToken(token);

            NavigationManager.NavigateTo("/", forceLoad: false);

            return(token);
        }
Exemple #2
0
        protected override async Task <AuthToken?> GetNewToken()
        {
            var code = await GetWorkflow();

            if (code?.State is null || code.Type != AuthWorkflowType.AuthCode)
            {
                return(null);
            }

            var result = await Request(
                "token",
                new AuthCode { Code = code.State });

            if (!string.IsNullOrEmpty(result.Error))
            {
                return(null);
            }

            var token = new AuthToken(result.Token.ExpiresInSec, result.Token.AccessToken, result.Token.Acquired);

            await SetToken(token);

            return(token);
        }