Exemplo n.º 1
0
        public static pCloudClient FromAuthToken(string authToken)
        {
            var handler = new EncodingRewriterMessageHandler {
                InnerHandler = new HttpClientHandler()
            };
            var client = new HttpClient(handler)
            {
                BaseAddress = new Uri("https://api.pcloud.com")
            };

            return(new pCloudClient(client, authToken));
        }
Exemplo n.º 2
0
        public static async Task<pCloudClient> CreateClientAsync(string username, string password)
        {
            var handler = new EncodingRewriterMessageHandler { InnerHandler = new HttpClientHandler() };
            var client = new HttpClient(handler) { BaseAddress = new Uri("https://api.pcloud.com") };
            var uri = string.Format("userinfo?getauth=1&logout=1&username={0}&password={1}", Uri.EscapeDataString(username), Uri.EscapeDataString(password));
            var userInfo = JsonConvert.DeserializeObject<dynamic>(await client.GetStringAsync(uri));
            if (userInfo.result != 0)
            {
                throw (Exception)CreateException(userInfo);
            }

            return new pCloudClient(client, (string)userInfo.auth);
        }
Exemplo n.º 3
0
        public static async Task <pCloudClient> CreateClientAsync(string username, string password)
        {
            var handler = new EncodingRewriterMessageHandler {
                InnerHandler = new HttpClientHandler()
            };
            var client = new HttpClient(handler)
            {
                BaseAddress = new Uri("https://api.pcloud.com")
            };
            var uri      = string.Format("userinfo?getauth=1&logout=1&username={0}&password={1}", Uri.EscapeDataString(username), Uri.EscapeDataString(password));
            var userInfo = JsonConvert.DeserializeObject <dynamic>(await client.GetStringAsync(uri));

            if (userInfo.result != 0)
            {
                throw (Exception)CreateException(userInfo);
            }

            return(new pCloudClient(client, (string)userInfo.auth));
        }
Exemplo n.º 4
0
		public static pCloudClient FromAuthToken(string authToken)
		{
            var handler = new EncodingRewriterMessageHandler { InnerHandler = new HttpClientHandler() };
            var client = new HttpClient(handler) { BaseAddress = new Uri("https://api.pcloud.com") };
            return new pCloudClient(client, authToken);
		}