Beispiel #1
0
        public void WhenGetAuthorizeUrlCalledThenUrlReturnedHasAppropiateUrlAndToken()
        {
            Settings   settings   = TestConfiguration.GetSettings();
            IBynderApi api        = BynderApiFactory.Create(settings);
            var        noCallback = api.GetAuthorizeUrl(null);

            Assert.AreEqual(string.Format("{0}api/v4/oauth/authorise/?oauth_token={1}", settings.URL, settings.TOKEN), noCallback);
        }
Beispiel #2
0
        public void WhenGetAuthorizeUrlCalledWithCallbackUrlThenUrlReturnedUrlAddsCallbackParameter()
        {
            Settings   settings    = TestConfiguration.GetSettings();
            IBynderApi api         = BynderApiFactory.Create(settings);
            string     callbackUrl = "http://localhost/";
            string     encodedUrl  = HttpUtility.UrlEncode(callbackUrl);
            var        noCallback  = api.GetAuthorizeUrl(callbackUrl);

            Assert.AreEqual(string.Format("{0}api/v4/oauth/authorise/?oauth_token={1}&callback={2}", settings.URL, settings.TOKEN, encodedUrl), noCallback);
        }
Beispiel #3
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();
                        }
                    }
                }
        }
        /// <summary>
        /// Main function
        /// </summary>
        /// <param name="args">arguments to main</param>
        public static void Main(string[] args)
        {
            using (IBynderApi bynderApi = BynderApiFactory.Create(Settings.FromJson("Config.json")))
            {
                // 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();
                string token = null;

                using (var listener = new OauthHttpListener("http://*****:*****@"Image/bynder-logo.png", BrandId = media.BrandId
                        }).Wait();
                        Console.WriteLine("Uploaded file to Bynder");
                    }
                }
            }
        }