public static async void Register(HttpConfiguration config) { // Web API configuration and services // Web API routes config.MapHttpAttributeRoutes(); config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); var api = new ViagogoClient("TaRJnBcw1ZvYOXENCtj5", "ixGDUqRA5coOHf3FQysjd704BPptwbk6zZreELW2aCYSmIT8XJ9ngvN1MuKV", new ProductHeaderValue("MyAwesomeApp")); var root = await api.Hypermedia.GetRootAsync(); Debug.WriteLine("My debug string here " + root); var searchResults = await api.Search.GetAllAsync("lady gaga"); var genres = await api.Categories.GetAllGenresAsync(); Console.WriteLine("Ok here it is " + genres); Console.WriteLine("Ladygaga " + searchResults); //var api = new ViagogoClient(new ProductHeaderValue("MyAwesomeApp"), "TaRJnBcw1ZvYOXENCtj5", "ixGDUqRA5coOHf3FQysjd704BPptwbk6zZreELW2aCYSmIT8XJ9ngvN1MuKV"); //var root = await api.Hypermedia.GetRootAsync(); }
public async System.Threading.Tasks.Task <ActionResult> Buy(string id) { var client = new ViagogoClient(new ProductHeaderValue("AwesomeApp", "1.0"), "TaRJnBcw1ZvYOXENCtj5", "ixGDUqRA5coOHf3FQysjd704BPptwbk6zZreELW2aCYSmIT8XJ9ngvN1MuKV"); var token = await client.OAuth2.GetClientAccessTokenAsync(/*List of scopes*/ new string[] { }); await client.TokenStore.SetTokenAsync(token); int idasint; Int32.TryParse(id, out idasint); var listings = await client.Listings.GetAllByEventAsync(idasint); var listcollection = new List <Models.Ticket>(); foreach (var res in listings) { listcollection.Add(new Models.Ticket() { price = res.EstimatedTotalTicketPrice, description = res.TicketType, noOfTickets = (int)res.NumberOfTickets }); } return(View(listcollection)); }
private static void InitializeContainer(Container container) { container.RegisterPerWebRequest <IVenueWatchRepository, VenueWatchRepository>(); container.RegisterPerWebRequest <ICurrentUserRetriever, CurrentUserRetriever>(); container.RegisterPerWebRequest <IViagogoClient>(() => { var client = new ViagogoClient(CLIENT_ID, CLIENT_SECRET, new ProductHeaderValue("VenueWatch")); if (!AdvancedExtensions.IsVerifying(container)) { // Its a shame to make it synchronous, but future plans will be to use another way of setting the token // so that we don't have to do this. var token = client.OAuth2.GetClientAccessTokenAsync(new[] { "read:user" }).Result; client.TokenStore.SetTokenAsync(token); } return(client); }); container.RegisterPerWebRequest <ApplicationUserManager>(() => new ApplicationUserManager(new UserStore <ApplicationUser>(new ApplicationDbContext()))); container.RegisterPerWebRequest <IAuthenticationManager>(() => AdvancedExtensions.IsVerifying(container) ? new OwinContext(new Dictionary <string, object>()).Authentication : HttpContext.Current.GetOwinContext().Authentication); }
public EventController() { const string clientId = "TaRJnBcw1ZvYOXENCtj5"; const string clientSecret = "ixGDUqRA5coOHf3FQysjd704BPptwbk6zZreELW2aCYSmIT8XJ9ngvN1MuKV"; _api = new ViagogoClient(new ProductHeaderValue("ShowMeApp"), clientId, clientSecret); }
//Parameter : category //Methos : This method uses category parameter to pull catgories that match from Viagogo API public async System.Threading.Tasks.Task <List <GogoKit.Models.Response.SearchResult> > SearchCategoryAsync(string category) { var api = new ViagogoClient(new ProductHeaderValue("AwesomeApp", "1.0"), "TaRJnBcw1ZvYOXENCtj5", "ixGDUqRA5coOHf3FQysjd704BPptwbk6zZreELW2aCYSmIT8XJ9ngvN1MuKV"); var searchResults = await api.Search.GetAllAsync(category); return(searchResults.ToList()); }
//Parameter : eventId //Methos : This method uses eventId parameter to pull Tickets for selected event // using Viagogo API public async Task <List <GogoKit.Models.Response.Listing> > SearchTicketsAsync(int eventId) { var api = new ViagogoClient(new ProductHeaderValue("AwesomeApp", "1.0"), "TaRJnBcw1ZvYOXENCtj5", "ixGDUqRA5coOHf3FQysjd704BPptwbk6zZreELW2aCYSmIT8XJ9ngvN1MuKV"); var ticketResult = await api.Listings.GetAllByEventAsync(eventId); return(ticketResult.ToList()); }
//Parameter : categoryId //Methos : This method uses categoryId parameter to pull Events that fall under the given category // using Viagogo API public async System.Threading.Tasks.Task <List <GogoKit.Models.Response.Event> > SearchEventsAsync(int categoryId) { var api = new ViagogoClient(new ProductHeaderValue("AwesomeApp", "1.0"), "TaRJnBcw1ZvYOXENCtj5", "ixGDUqRA5coOHf3FQysjd704BPptwbk6zZreELW2aCYSmIT8XJ9ngvN1MuKV"); var categoryResults = await api.Categories.GetAsync(categoryId); var eventResults = await api.Events.GetAllByCategoryAsync(categoryResults.Id.Value); return(eventResults.ToList()); }
public VenueRetrieve() { _client = new ViagogoClient(CLIENT_ID, CLIENT_SECRET, new ProductHeaderValue("AwesomeApp", "1.0")); var token = await _client.OAuth2.GetAccessTokenAsync(); await client.TokenStore.SetTokenAsync(token); }
public async Task <String> GetAccessToken() { // TODO: cache tokens in session store, and replace them only when expired var api = new ViagogoClient( new ProductHeaderValue("EventViewer"), "clientId", "clientSecret"); return((await api.OAuth2.GetClientAccessTokenAsync(new string[] { })).AccessToken); }
public async Task ShouldReceiveResultsFromViagogoApi() { var credentialProvider = new CredentialProvider(); //Given var sut = new ViagogoClient(new ProductHeaderValue(AppName), credentialProvider.ClientId, credentialProvider.ClientSecret); //When var root = await sut.Hypermedia.GetRootAsync(); //Then root.Should().NotBe(null); }
public async Task <ActionResult> Lookup(SearchString search) { search.searchStr = search.searchStr == null ? "EMPTY SEARCH" : search.searchStr; if (search.searchStr == "EMPTY SEARCH") { return(RedirectToAction("Index", new { id = 1 })); } var existsEvent = false; var client = new ViagogoClient(new ProductHeaderValue("AwesomeApp", "1.0"), "TaRJnBcw1ZvYOXENCtj5", "ixGDUqRA5coOHf3FQysjd704BPptwbk6zZreELW2aCYSmIT8XJ9ngvN1MuKV"); var token = await client.OAuth2.GetClientAccessTokenAsync(/*List of scopes*/ new string[] { }); await client.TokenStore.SetTokenAsync(token); var searchResults = await client.Search.GetAllAsync(search.searchStr); List <Models.Event> eventcollection = new List <Models.Event>(); foreach (var res in searchResults) { if (res.Type == "Event") { var currEvent = await client.Hypermedia.GetAsync <GogoKit.Models.Response.Event>(res.EventLink); eventcollection.Add(new Models.Event() { eventName = res.Title, minticketprice = conv(currEvent.MinTicketPrice), eventDate = currEvent.StartDate, noofTickets = currEvent.NumberOfTickets, id = currEvent.Id }); existsEvent = true; } } Session["events"] = eventcollection; if (existsEvent) { FilterModel filterobject = new FilterModel(); filterobject.lst = eventcollection; return(View(filterobject)); } else { return(RedirectToAction("Index", new { id = 1 })); } }
protected async Task InitAsync(string myApplicationName) { if (myApplicationName.IsNullOrWhiteSpace()) { throw new ArgumentException("Cannot be null or empty", myApplicationName); } _viagogoClient = new ViagogoClient( new ProductHeaderValue(myApplicationName), _credentialProvider.ClientId, _credentialProvider.ClientSecret); _token = await _viagogoClient.OAuth2.GetClientAccessTokenAsync(new List <string>()); await _viagogoClient.TokenStore.SetTokenAsync(_token); }
public static void Main(string[] args) { const string ClientId = "YOUR_CLIENT_ID"; const string ClientSecret = "YOUR_CLIENT_SECRET"; // Refresh tokens are issued with every OAuth token that your application // receives using the Authorization Code Grant type. // see http://developer.viagogo.net/#authorization-code-grant const string RefreshToken = "YOUR_REFRESH_TOKEN"; // You can create your own custom implementation of IOAuth2TokenStore that // stores tokens for users in a database or in user cookies, etc var oauth2TokenStore = CreateOAuth2TokenStore(RefreshToken).Result; var viagogoClient = new ViagogoClient(ClientId, ClientSecret, new ProductHeaderValue("GogoKit-Samples"), new GogoKitConfiguration(), oauth2TokenStore); Console.WriteLine("Getting current OAuth2 token"); var currentToken = viagogoClient.TokenStore.GetTokenAsync().Result; var tokenExpirationDate = currentToken.IssueDate.AddSeconds(currentToken.ExpiresIn); if (tokenExpirationDate >= DateTimeOffset.UtcNow) { Console.WriteLine("OAuth2 token is expired so refreshing the token"); // The token is expired so refresh it var newAccessToken = viagogoClient.OAuth2.RefreshAccessTokenAsync(currentToken).Result; Console.WriteLine("Saving new OAuth2 token"); viagogoClient.TokenStore.SetTokenAsync(newAccessToken).Wait(); Console.WriteLine("We've refreshed our token and saved the new one"); } else { Console.WriteLine("OAuth2 token is still valid so continue using it"); } Console.WriteLine("Press ENTER to exit"); Console.ReadLine(); }
public void Setup() { var credentialProvider = new CredentialProvider();; _viagogoClient = new ViagogoClient(new ProductHeaderValue("MyApplication"), credentialProvider.ClientId, credentialProvider.ClientSecret); _mockResults = new Mock <IReadOnlyList <SearchResult> >(); _mockApi = new Mock <IViagogoClient>(); _mockApi .Setup(m => m.Search.GetAllAsync(It.IsAny <string>())) .Returns(Task.FromResult(_mockResults.Object)); _mockApiProvider = new Mock <IViagogoApiProvider>(); _mockApiProvider .Setup(m => m.GetViagogoApiClient()) .Returns(_mockApi.Object); }
public async Task ShouldBeAbleToSetAToken() { var credentialProvider = new CredentialProvider();; //Given var sut = new ViagogoClient(new ProductHeaderValue(AppName), credentialProvider.ClientId, credentialProvider.ClientSecret); //When Func <Task> asyncFunc = async() => { var token = await sut.OAuth2.GetClientAccessTokenAsync(new List <string>()); await sut.TokenStore.SetTokenAsync(token); }; //Then asyncFunc.ShouldNotThrow(); }
public async Task GetEventDetails() { var api = new ViagogoClient(new ProductHeaderValue("ShowMeApp"), ClientId, ClientSecret); var searchResults = await api.Search.GetAllAsync("john legend"); var categoryId = GetIdFromLink(searchResults[0].CategoryLink.HRef); var events = await api.Events.GetAllByCategoryAsync(categoryId); events.ShouldNotBeEmpty(); var eventDetails = await api.Events.GetAsync(events[0].Id.Value); eventDetails.Id.ShouldNotBeNull(); var listings = await api.Listings.GetAllByEventAsync(eventDetails.Id.Value); listings.Count.ShouldBeGreaterThanOrEqualTo(0); }
public async Task SearchForArtistEvents() { var api = new ViagogoClient(new ProductHeaderValue("ShowMeApp"), ClientId, ClientSecret); //var root = await api.Hypermedia.GetRootAsync(); var searchResults = await api.Search.GetAllAsync("john legend"); searchResults.ShouldNotBeEmpty(); searchResults[0].Type.ShouldBe("Category"); var categoryId = GetIdFromLink(searchResults[0].CategoryLink.HRef); categoryId.ShouldBeGreaterThan(0); var category = await api.Categories.GetAsync(categoryId); var events = await api.Events.GetAllByCategoryAsync(category.Id.Value); events.ShouldNotBeEmpty(); }