Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- curl https://auth.iot.blackberry.com/auth/token --key ./private_key.key --cert ./certificate.pem -d grant_type=password -d username="" -d password=""
- Dim token As String = ""
- Dim uriVar As New Uri("https://someWebSite.com/test")
- Dim user As String = ""
- Dim password As String = ""
- Dim request As HttpWebRequest = CType(WebRequest.Create(uriVar), HttpWebRequest)
- request.KeepAlive = False
- request.ProtocolVersion = HttpVersion.Version11
- request.Method = "POST"
- Dim credential As New NetworkCredential(user, password)
- request.Credentials = credential
- Dim keystoreFileName As String = "keystore.p12"
- Dim pathCert As String = Path.Combine(Environment.CurrentDirectory, "cert", keystoreFileName)
- Dim cert As New X509Certificate(pathCert, "allpassword")
- request.ClientCertificates.Add(cert)
- request.ContentType = "application/x-www-form-urlencoded"
- request.ContentLength = 39
- request.Accept = "*/*"
- Dim requestStream As Stream = request.GetRequestStream()
- Dim post_data As String = "grant_type=password&username=&password="
- Dim postBytes As Byte() = Encoding.ASCII.GetBytes(post_data)
- requestStream.Write(postBytes, 0, postBytes.Length)
- requestStream.Close()
- Dim response As HttpWebResponse = CType(request.GetResponse(), HttpWebResponse)
- Dim responseJson = New StreamReader(response.GetResponseStream()).ReadToEnd()
- Return responseJson
Add Comment
Please, Sign In to add comment