public SpotifyAuthorization Authorize() { string userId = GetUserId(); var userAuth = _authService.GetUserAuth(userId); if (userAuth != null && userAuth.Authorized) { return(MapToSpotifyAuthorization(userAuth)); } if (userAuth == null) { userAuth = _authService.CreateUserAuth(userId); } // create a state value and persist it until the callback string state = _stateService.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 SpotifyAuthorization { UserId = userId, Authorized = false, AuthorizationUrl = url }); }