Beispiel #1
0
        public static void AddTogglAuth(this IRestRequest req, TogglAuthRequest auth)
        {
            string encodedAuthString = String.IsNullOrWhiteSpace(auth.ApiToken) ?
                Convert.ToBase64String(Encoding.UTF8.GetBytes(auth.UserName + ":" + auth.Password)) :
                Convert.ToBase64String(Encoding.UTF8.GetBytes(auth.ApiToken + ":api_token"));

            req.AddHeader("Authorization", "Basic " + encodedAuthString);
        }
Beispiel #2
0
        //
        // GET: /Home/
        public ActionResult Index()
        {
            TogglAuthRequest auth = new TogglAuthRequest {
                ApiToken = "67be300bcfc9c09f40636074303ce3ff"
            };

            TogglApi api = new TogglApi(auth);
            var val = api.Users.GetCurrent();

            var clients = api.Clients.Get();

            ViewBag.Content = val.ToString();

            return View();
        }
Beispiel #3
0
 public TogglApi(TogglAuthRequest authRequest)
 {
     _authRequest = authRequest;
 }