Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.55 KB | None | 0 0
  1. public void LogIn()
  2.     {
  3.  
  4.         string username = "xxx";
  5.         string password = "xxx";
  6.         string url = "http://xxxxx/api/token/";
  7.  
  8.         HttpWebRequest tokenRequest = (HttpWebRequest)WebRequest.Create(url);
  9.         string encoded = System.Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(username + ":" + password));
  10.         tokenRequest.Headers.Add("Authorization", "Basic " + encoded); 
  11.         tokenRequest.Method = "POST";
  12.         HttpWebResponse tokenResponse = (HttpWebResponse)tokenRequest.GetResponse();
  13.         Debug.Log (tokenResponse);
  14.  
  15.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement