-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathauthentication.cs
More file actions
35 lines (30 loc) · 1.17 KB
/
authentication.cs
File metadata and controls
35 lines (30 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System;
using System.IO;
using System.Net;
namespace Decodo_API
{
class authentication
{
static void Main(string[] args)
{
string uri = "https://api.decodo.com/v1/auth";
// Your Decodo credentials
string username = "";
string password = "";
string encoded = Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(username + ":" + password));
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
request.PreAuthenticate = true;
request.Headers.Add("Authorization", "Basic " + encoded);
request.ContentType = "application/json";
request.Method = "POST";
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
using (Stream stream = response.GetResponseStream())
using (StreamReader reader = new StreamReader(stream))
{
Console.WriteLine(reader.ReadToEnd());
Console.ReadKey();
}
}
}
}