Guest User

Untitled

a guest
Jan 8th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. curl https://auth.iot.blackberry.com/auth/token --key ./private_key.key --cert ./certificate.pem -d grant_type=password -d username="" -d password=""
  2.  
  3. Dim token As String = ""
  4. Dim uriVar As New Uri("https://someWebSite.com/test")
  5. Dim user As String = ""
  6. Dim password As String = ""
  7.  
  8.  
  9.  
  10. Dim request As HttpWebRequest = CType(WebRequest.Create(uriVar), HttpWebRequest)
  11. request.KeepAlive = False
  12. request.ProtocolVersion = HttpVersion.Version11
  13. request.Method = "POST"
  14.  
  15. Dim credential As New NetworkCredential(user, password)
  16. request.Credentials = credential
  17. Dim keystoreFileName As String = "keystore.p12"
  18. Dim pathCert As String = Path.Combine(Environment.CurrentDirectory, "cert", keystoreFileName)
  19. Dim cert As New X509Certificate(pathCert, "allpassword")
  20. request.ClientCertificates.Add(cert)
  21.  
  22.  
  23. request.ContentType = "application/x-www-form-urlencoded"
  24. request.ContentLength = 39
  25. request.Accept = "*/*"
  26.  
  27. Dim requestStream As Stream = request.GetRequestStream()
  28. Dim post_data As String = "grant_type=password&username=&password="
  29. Dim postBytes As Byte() = Encoding.ASCII.GetBytes(post_data)
  30. requestStream.Write(postBytes, 0, postBytes.Length)
  31. requestStream.Close()
  32.  
  33. Dim response As HttpWebResponse = CType(request.GetResponse(), HttpWebResponse)
  34. Dim responseJson = New StreamReader(response.GetResponseStream()).ReadToEnd()
  35.  
  36. Return responseJson
Add Comment
Please, Sign In to add comment