示例#1
0
        public GetAddesssApi(ApiKey apiKey, AdminKey adminKey, HttpClient httpClient = null)
        {
            _client = httpClient ?? new HttpClient {
                BaseAddress = _baseAddress
            };

            _client.DefaultRequestHeaders.TryAddWithoutValidation("accept", "application/json");

            AdminKey = adminKey;

            ApiKey = apiKey;

            DomainWhitelist = new DomainWhitelistApi(AdminKey, this);

            IpAddressWhitelist = new IpAddressWhitelistApi(AdminKey, this);

            PrivateAddress = new PrivateAddressApi(AdminKey, this);

            Usage = new UsageApi(AdminKey, this);

            BillingAddress = new BillingAddressApi(AdminKey, this);

            Address = new AddressApi(ApiKey, this);

            FirstLimitReachedWebhook = new FirstLimitReachedWebhookApi(AdminKey, this);

            Subscription = new SubscriptionApi(adminKey, this);

            ApiKeyApi = new ApiKeyApi(adminKey, this);
        }
示例#2
0
        protected override async Task <string> PrepareUrl(string path, bool authenticated = true)
        {
            if (AuthLocation != AuthLocation.Query)
            {
                return(await base.PrepareUrl(path, authenticated));
            }
            var newPath = await ApiKeyApi.PrepareUrl(BaseAddress, path, ApiKey, AuthKey, AuthLocation);

            if (authenticated)
            {
                newPath = await ApiKeyApi.PrepareUrl(BaseAddress, newPath, CurrentOAuthAccount.Token, "oauth_token", AuthLocation.Query);
            }
            return(newPath);
        }
示例#3
0
        public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            SimpleAuth.OnePassword.Activate();
            SimpleAuth.NativeSafariAuthenticator.Activate();
            SimpleAuth.Providers.Google.Init();

            googleApi = new GoogleApi("google", "419855213697-t0usvf1n0j1vd9glogcp33b4d2fnfjhn.apps.googleusercontent.com")
            {
                ServerClientId = "419855213697-uq56vcune334omgqi51ou7jg08i3dnb1.apps.googleusercontent.com",
                ForceRefresh   = true,
                Scopes         = new []
                {
                    "https://www.googleapis.com/auth/userinfo.email",
                    "https://www.googleapis.com/auth/userinfo.profile"
                }
            };
            googleApi.ResetData();
            apiKeyApi = new ApiKeyApi("myapikey", "api_key", AuthLocation.Query)
            {
                BaseAddress = new Uri("http://petstore.swagger.io/v2"),
            };

            Api.UnhandledException += (sender, e) => {
                Console.WriteLine(e);
            };
            // create a new window instance based on the screen size
            Window = new UIWindow(UIScreen.MainScreen.Bounds);

            Window.RootViewController = new DialogViewController(new RootElement("Simple Auth")
            {
                new Section("Google Api")
                {
                    new StringElement("Authenticate", async() => {
                        try{
                            var account = await googleApi.Authenticate();
                            ShowAlert("Success", "Authenticate");
                        }
                        catch (TaskCanceledException) {
                            ShowAlert("Canceled", "");
                        }
                        catch (Exception ex)
                        {
                            ShowAlert("Error", ex.ToString());
                        }
                    }),
                    new StringElement("Log out", () => {
                        googleApi.ResetData();
                        ShowAlert("Success", "Logged out");
                    }),
                },
                new Section("Api Key Api")
                {
                    new StringElement("Get", async() => await RunWithSpinner("Querying", async() => {
                        var account = await apiKeyApi.Get("http://petstore.swagger.io/v2/store/inventory?test=test1");
                        ShowAlert("Success", "Querying");
                    })),
                },
                new Section("Basic Auth")
                {
                    new StringElement("Login to Github", async() => {
                        var account = await basicApi.Authenticate();
                        ShowAlert("Success", "Authenticated");
                    }),
                    new StringElement("Log out", () => {
                        basicApi.ResetData();
                        ShowAlert("Success", "Logged out");
                    }),
                }
            });

            // make the window visible
            Window.MakeKeyAndVisible();

            return(true);
        }
示例#4
0
 public void Init()
 {
     instance = new ApiKeyApi();
 }
示例#5
0
        public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            SimpleAuth.Providers.Google.Init();

            googleApi = new GoogleApi("google", "419855213697-t0usvf1n0j1vd9glogcp33b4d2fnfjhn.apps.googleusercontent.com")
            {
                ServerClientId = "419855213697-uq56vcune334omgqi51ou7jg08i3dnb1.apps.googleusercontent.com",
                ForceRefresh   = true,
                Scopes         = new []
                {
                    "https://www.googleapis.com/auth/userinfo.email",
                    "https://www.googleapis.com/auth/userinfo.profile"
                }
            };
            apiKeyApi = new ApiKeyApi("myapikey", "api_key", AuthLocation.Query)
            {
                BaseAddress = new Uri("http://petstore.swagger.io/v2"),
            };
            string azureTennant  = "";
            string azureClientId = "";

            azureApi = new ADFSApi("Azure", azureClientId,
                                   $"https://login.microsoftonline.com/{azureTennant}/oauth2/authorize",
                                   $"https://login.microsoftonline.com/{azureTennant}/oauth2/token", "");
            Api.UnhandledException += (sender, e) => {
                Console.WriteLine(e);
            };
            // create a new window instance based on the screen size
            Window = new UIWindow(UIScreen.MainScreen.Bounds);

            Window.RootViewController = new DialogViewController(new RootElement("Simple Auth")
            {
                new Section("Google Api")
                {
                    new StringElement("Authenticate", async() => {
                        try{
                            var account = await googleApi.Authenticate();
                            ShowAlert("Success", "Authenticate");
                        }
                        catch (TaskCanceledException) {
                            ShowAlert("Canceled", "");
                        }
                        catch (Exception ex)
                        {
                            ShowAlert("Error", ex.ToString());
                        }
                    }),
                    new StringElement("Log out", () => {
                        googleApi.ResetData();
                        ShowAlert("Success", "Logged out");
                    }),
                },
                new Section("Api Key Api")
                {
                    new StringElement("Get", async() => await RunWithSpinner("Querying", async() => {
                        var account = await apiKeyApi.Get("http://petstore.swagger.io/v2/store/inventory?test=test1");
                        ShowAlert("Success", "Querying");
                    })),
                },
                new Section("Basic Auth")
                {
                    new StringElement("Login to Github", async() => {
                        var account = await basicApi.Authenticate();
                        ShowAlert("Success", "Authenticated");
                    }),
                    new StringElement("Log out", () => {
                        basicApi.ResetData();
                        ShowAlert("Success", "Logged out");
                    }),
                },
                new Section("Fitbit")
                {
                    new StringElement("Login to server", async() =>
                    {
                        fitBitApi.Scopes = new [] { "profile", "settings" };
                        var account      = await fitBitApi.Authenticate();
                        ShowAlert("Success", "Authenticated");
                    }),
                    new StringElement("Call Api", async() =>
                    {
                        var devices = await fitBitApi.Get("https://api.fitbit.com/1/user/-/devices.json");
                        ShowAlert("Success", devices);
                    }),
                    new StringElement("Log out", () => {
                        fitBitApi.ResetData();
                        ShowAlert("Success", "Logged Out");
                    })
                },
                new Section("Azure AD")
                {
                    new StringElement("Login", async() => {
                        var account  = await azureApi.Authenticate();
                        var userData = await azureApi.Get("https://graph.windows.net/me?api-version=1.6");
                        ShowAlert("Success", "Authenticated");
                    }),
                    new StringElement("Log out", () => {
                        azureApi.Logout();
                        ShowAlert("Success", "Logged out");
                    }),
                }
            });

            // make the window visible
            Window.MakeKeyAndVisible();

            return(true);
        }