static void Main() { AppAuthenticator.Initialize(new AppAuthInfo { ApplicationId = "a9f92fd992674bee8142a35501369335", SharedSecret = "be48336d7ee84bfca0c8a35501369335" }, "https://home.mozu.com"); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new FormMain()); }
private async void btnAuthenticate_Click(object sender, EventArgs e) { try { if (txtApplicationID.Text.Length > 20 && txtSharedSecret.Text.Length > 20) { btnAuthenticate.Text = "Authenticating..."; var appAuthInfo = new AppAuthInfo { ApplicationId = txtApplicationID.Text, SharedSecret = txtSharedSecret.Text }; if (txtEmail.Text.Contains("@") && txtEmail.Text.Contains(".") && txtPassword.Text.Length > 5) { await AppAuthenticator.InitializeAsync(appAuthInfo); btnAuthenticate.Text = "Loading Scopes..."; panelAPI.Visible = true; panelTenant.Visible = true; var userAuthInfo = new UserAuthInfo { EmailAddress = txtEmail.Text, Password = txtPassword.Text }; _userInfo = await UserAuthenticator.AuthenticateAsync(userAuthInfo, AuthenticationScope.Tenant); panelTenant.Visible = true; _userInfo.AuthorizedScopes.Insert(0, new Scope { Id = -1, Name = "[Select Tenant]" }); cbTenant.DataSource = _userInfo.AuthorizedScopes; btnAuthenticate.Text = "Renew Authentication"; } else { btnAuthenticate.Text = "Authenticate"; LogError(new Exception("Not enough User data entered for User Scope Authentication")); } } else { LogError(new Exception("Not enough Application data entered for Authentication")); } } catch (ApiException exc) { LogError(exc); btnAuthenticate.Text = "Authenticate"; } }
public static void AuthApp(string mozuApplicationId, string mozuApplicationSecret) { MozuApplicationId = mozuApplicationId; MozuApplicationSecret = mozuApplicationSecret; MozuConfig.ThrowExceptionOn404 = true; // auth with mozu _mozuAppAuthInfo = new AppAuthInfo() { ApplicationId = MozuApplicationId, SharedSecret = MozuApplicationSecret }; AppAuthenticator.Initialize(_mozuAppAuthInfo); isAuthed = true; }
/// <summary> /// Authenticate The Application (SDK Tests) /// </summary> /// <param name="appId"></param> /// <param name="sharedSecret"></param> /// <param name="baseAuthAppUrl"></param> public static void AuthenticateSdk(string appId, string sharedSecret, string baseAuthAppUrl) { try { MozuConfig.BaseAppAuthUrl = BaseAuthAppUrl; AppAuthenticator.Initialize( appAuthInfo: new AppAuthInfo() { ApplicationId = AppId, SharedSecret = SharedSecret }); IsIntialized = true; } catch (Exception ex) { throw new Exception("App Authentication did not work. " + ex.Message); } }
public void SimpleAppAuthLoginTest() { var baseAppAuthUrl = "http://aus02ndserv001.dev.volusion.com/Mozu.AppDev.WebApi/platform/applications/authtickets/"; var appId = "158496f0ca114e0b88bda2ed011dc745"; var sharedSecret = "3c9a6a0bd09b44d1a7c7a2ed011dc745"; var appAuthInfo = new AppAuthInfo { ApplicationId = appId, SharedSecret = sharedSecret }; MozuConfig.BaseAppAuthUrl = baseAppAuthUrl; var authenticator = AppAuthenticator.Initialize(appAuthInfo); authenticator.EnsureAuthTicket(); Assert.IsNotNull(appAuthInfo); Assert.IsNotNull(appAuthInfo.ApplicationId); Assert.IsNotNull(appAuthInfo.SharedSecret); }
public async Task AsyncTest() { var baseAppAuthUrl = "http://home.mozu-ci.volusion.com/"; var appId = "5d76bb2a852d4741939fa27d00d98a40"; var sharedSecret = "348f780339b749b58d3fa27d00d98a40"; var appAuthInfo = new AppAuthInfo { ApplicationId = appId, SharedSecret = sharedSecret }; MozuConfig.BaseAppAuthUrl = baseAppAuthUrl; await AppAuthenticator.InitializeAsync(appAuthInfo); Assert.IsNotNull(AppAuthenticator.Instance); Assert.IsNotNull(AppAuthenticator.Instance.AppAuthTicket); Assert.IsNotNull(AppAuthenticator.Instance.AppAuthTicket.AccessToken); //var tenantResource = new TenantResource(); //var tenant = await tenantResource.GetTenantAsync(9539); //Assert.IsNotNull(tenant); //Assert.AreEqual(tenant.Id, 9539); }
private void InitDependencyResolvers() { var appName = ConfigurationManager.AppSettings["AppName"]; var configPath = ConfigurationManager.AppSettings["ConfigPath"]; var environment = ConfigurationManager.AppSettings["Environment"]; if (!string.IsNullOrEmpty(appName) && !string.IsNullOrEmpty(configPath) && !String.IsNullOrEmpty(environment)) { var appParams = new List <NamedParameter> { new NamedParameter("configPath", configPath), new NamedParameter("appName", appName), new NamedParameter("environment", environment) }; _containerBuilder.RegisterType <AppSetting>().As <IAppSetting>().SingleInstance().WithParameters(appParams); } else { _containerBuilder.RegisterType <AppSetting>().As <IAppSetting>().SingleInstance(); } _containerBuilder.RegisterType <Log4NetServiceFactory>().As <ILoggingServiceFactory>().SingleInstance(); if (ConfigurationManager.AppSettings.AllKeys.Contains("UseGenericEventService") && bool.Parse(ConfigurationManager.AppSettings["UseGenericEventService"])) { _containerBuilder.RegisterType <Events.GenericEventService>().As <IEventService>(); } else { _containerBuilder.RegisterType <Events.EventService>().As <IEventService>(); } _containerBuilder.RegisterType <Events.EventServiceFactory>().As <IEventServiceFactory>(); _containerBuilder.RegisterAssemblyTypes(Assembly.GetExecutingAssembly()) .Where(t => t.Name.EndsWith("Handler")) .AsImplementedInterfaces(); _containerBuilder.RegisterType <EntitySchemaHandler>().As <IEntitySchemaHandler>(); _containerBuilder.RegisterType <ReturnEventProcessor>().Keyed <IEventProcessor>(EventCategory.Return); _containerBuilder.RegisterType <ProductEventProcessor>().Keyed <IEventProcessor>(EventCategory.Product); _containerBuilder.RegisterType <OrderEventProcessor>().Keyed <IEventProcessor>(EventCategory.Order); _containerBuilder.RegisterType <ApplicationEventProcessor>().Keyed <IEventProcessor>(EventCategory.Application); _containerBuilder.RegisterType <CustomerAccountEventProcessor>().Keyed <IEventProcessor>(EventCategory.CustomerAccount); _containerBuilder.RegisterType <DiscountEventProcessor>().Keyed <IEventProcessor>(EventCategory.Discount); _containerBuilder.RegisterType <CustomerSegmentEventProcessor>().Keyed <IEventProcessor>(EventCategory.CustomerSegment); _containerBuilder.RegisterType <TenantEventProcessor>().Keyed <IEventProcessor>(EventCategory.Tenant); _containerBuilder.RegisterType <EmailEventProcessor>().Keyed <IEventProcessor>(EventCategory.Email); InitializeContainer(_containerBuilder); Container = _containerBuilder.Build(); LogManager.LoggingService = Container.Resolve <ILoggingServiceFactory>().GetLoggingService(); var appSetting = Container.Resolve <IAppSetting>(); if (!string.IsNullOrEmpty(appSetting.ApplicationId) && !string.IsNullOrEmpty(appSetting.SharedSecret)) { if (!string.IsNullOrEmpty(appSetting.BaseUrl)) { MozuConfig.BaseAppAuthUrl = appSetting.BaseUrl; } if (!string.IsNullOrEmpty(appSetting.BasePCIUrl)) { MozuConfig.BasePciUrl = appSetting.BasePCIUrl; } var appAuthenticator = AppAuthenticator.InitializeAsync(new AppAuthInfo { ApplicationId = appSetting.ApplicationId, SharedSecret = appSetting.SharedSecret }).Result; } PostInitialize(); }