Blue Theme Orange Theme Green Theme Red Theme
 
Home | Forums | Videos | Advertise | Certifications | Downloads | Blogs | Interviews | Jobs | Beginners | Training
 | Consulting  
Submit an Article Submit a Blog 
 Jump to
Skip Navigation Links
Search :       Advanced Search �
Home

Author Rank :
Page Views :
Downloads : 0
Rating :
 Rate it
Level :
Become a Sponsor
Tags


There are so many APIs that we cannot use directly. Some of them require an authorized Token first and then we can use that Token to Authenticate that API.

The following is sample code to authenticate an API:

Dim WebServiceURI As String = "API Url"

 

        Dim webrequestobj As HttpWebRequest = DirectCast(WebRequest.Create(WebServiceURI), HttpWebRequest)

        Dim soapAction = ""

        Dim WebServiceData As StringBuilder = New StringBuilder

 

        Dim WebServiceByteData As Byte() = Encoding.UTF8.GetBytes(WebServiceData.ToString)

 

        webrequestobj.Method = "GET"

        webrequestobj.ContentType = "application/json"

        webrequestobj.Credentials = CredentialCache.DefaultCredentials

        webrequestobj.Headers.Add(HttpRequestHeader.Authorization, "AuthoreizeToken")

 

        Try

            Using Response As HttpWebResponse = TryCast(webrequestobj.GetResponse(), HttpWebResponse)

                Dim reader As New StreamReader(Response.GetResponseStream())

                Dim str As String = reader.ReadLine()

            

            End Using

        Catch ex As Exception

          

        End Try

 [Top] Rate this article
 
 About the author
 
Author
 Post a Feedback, Comment, or Question about this article
Subject:
Comment:
 Comments

 � 2025  contents copyright of their authors. Rest everything copyright Mindcracker. All rights reserved.