Esempio n. 1
0
        /// <summary>
        /// Main function
        /// </summary>
        /// <param name="args">arguments to main</param>
        public static void Main(string[] args)
        {
            using (var waitForToken = new WaitForToken())
                using (IBynderApi bynderApi = BynderApiFactory.Create(new Settings
                {
                    CONSUMER_KEY = ConfigurationManager.AppSettings["CONSUMER_KEY"],
                    CONSUMER_SECRET = ConfigurationManager.AppSettings["CONSUMER_SECRET"],
                    TOKEN = ConfigurationManager.AppSettings["TOKEN"],
                    TOKEN_SECRET = ConfigurationManager.AppSettings["TOKEN_SECRET"],
                    URL = ConfigurationManager.AppSettings["API_BASE_URL"]
                }))
                {
                    // We login using the browser. To do that we have to do the following:
                    // 1. Request temporary tokens
                    // 2. Get an authorized Url passing a callback where we will be redirected when login is successful.
                    // 3. Open a browser with the authorized Url and start listening to the callback url.
                    // 4. User logs in.
                    // 5. We request final access tokens.
                    bynderApi.GetRequestTokenAsync().Wait();
                    using (var listener = new OauthHttpListener("http://*****:*****@"Image/bynder-logo.png", BrandId = media.BrandId
                            }).Wait();
                        }
                    }
                }
        }
        private static async Task QueryBynderUsingOAuth(IBynderClient client)
        {
            using var waitForToken = new WaitForToken();
            using var listener     = new UrlHttpListener("http://localhost:8888/", waitForToken);

            Browser.Launch(client.GetOAuthService().GetAuthorisationUrl("state example", "offline asset:read collection:read"));
            waitForToken.WaitHandle.WaitOne(50000);

            if (waitForToken.Success)
            {
                client.GetOAuthService().GetAccessTokenAsync(waitForToken.Token, "offline asset:read collection:read").Wait();
                await QueryBynder(client);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Main function
        /// </summary>
        /// <param name="args">arguments to main</param>
        public static void Main(string[] args)
        {
            using (var client = ClientFactory.Create(Configuration.FromJson("Config.json")))
            {
                var mediaList = client.GetAssetService().GetMediaListAsync(new MediaQuery()).Result;

                foreach (var media in mediaList)
                {
                    Console.WriteLine(media.Name);
                }

                var collectionList = client.GetCollectionService().GetCollectionsAsync(new GetCollectionsQuery()).Result;

                foreach (var collection in collectionList)
                {
                    Console.WriteLine(collection.Name);
                }
            }

            using (var waitForToken = new WaitForToken())
            {
                using (var listener = new UrlHttpListener("http://localhost:8888/", waitForToken))
                {
                    using (var client = ClientFactory.Create(Configuration.FromJson("Config.json")))
                    {
                        Browser.Launch(client.GetOAuthService().GetAuthorisationUrl("state example", "offline asset:read collection:read"));
                        waitForToken.WaitHandle.WaitOne(50000);

                        if (waitForToken.Success)
                        {
                            client.GetOAuthService().GetAccessTokenAsync(waitForToken.Token, "offline asset:read collection:read").Wait();

                            var mediaList = client.GetAssetService().GetMediaListAsync(new MediaQuery()).Result;

                            foreach (var media in mediaList)
                            {
                                Console.WriteLine(media.Name);
                            }

                            var collectionList = client.GetCollectionService().GetCollectionsAsync(new GetCollectionsQuery()).Result;

                            foreach (var collection in collectionList)
                            {
                                Console.WriteLine(collection.Name);
                            }
                        }
                    }
                }
            }
        }