public async Task <AuthorizationResult> Authorize() { string userId = HttpHelper.GetUserId(HttpContext); //if (await _tokenService.HasAccessToken(userId)) return new AuthorizationResult { UserId = userId, Authorized = true }; // create a state value and persist it until the callback string state = await _userStateService.NewState(userId); // generate an Authorization URL for the read and modify playback scopes string url = _userAccounts.AuthorizeUrl(state, new[] { "user-read-playback-state", "user-modify-playback-state" }); return(new AuthorizationResult { UserId = userId, Authorized = false, AuthorizationUrl = url }); }