Solved

User Authentication and Read XML from URL in ASP.NET

Posted on 2009-05-06
1
305 Views
Last Modified: 2012-05-06
User Authentication*:

In API I need to have authentificate by "user name" and your "password".
First, I have to request an api-signature by requesting "http://www.xyz.com/api/get_api_signature.php".
Next, I have to build an auth_token. auth_token=md5(md5(password)+api_signature).
At last I have to send your "user name" (auth_user_name=<user_name>), the requested "api-signature" (api_signature=<api_signature>) and  auth_token (auth_token=<auth_token>) with normal api-request.
The Api-Signature is valid for 1 minute.

Example :
1. Request api-signature: GET -> http://www.xyz.com/api/get_api_signature.php
2. Answer of the request: "8b55eac3b2291b201fc59cd8b76410ab"
3. Build auth_token:
    md5(md5("testpassword")+"8b55eac3b2291b201fc59cd8b76410ab") =
    md5("e16b2ab8d12314bf4efbd6203906ea6c"+"8b55eac3b2291b201fc59cd8b76410ab") =
    "c8b066236c8cbcc280921b93f24e281a"
4. Parameters:
    auth_user_name="testuser",
    api_signature="8b55eac3b2291b201fc59cd8b76410ab",
    auth_token="c8b066236c8cbcc280921b93f24e281a"
5. Request: http://www.xyz.com/api/get_photos_xml.php?category=submitted&auth_user_name=testuser&api_signature=8b55eac3b2291b201fc59cd8b76410ab&auth_token=c8b066236c8cbcc280921b93f24e281a&user_name=testuser&size=large&locr=true

Now how I execute these steps in ASP.net 2.
Result of URL need to take it in Data Set to display in Grid.

Thanks,
Regards,
0
Comment
Question by:FairGuy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

by:
FairGuy earned 0 total points
ID: 24343985
Hi All,

Now I solve this Problem by My Self, I worte class library name ClassLibrary,vb for MD5 and URLGet value.

Imports System.Security.Cryptography
Imports IST
Imports System.IO
Imports System.Net
Imports System.Text
Imports Microsoft.VisualBasic
Public Class ClassLibrary
    Public NotInheritable Class PhpCompatible
        Public Shared Function Md5Hash(ByVal pass As String) As String
            Dim md5 As MD5 = MD5CryptoServiceProvider.Create()
            Dim dataMd5 As Byte() = md5.ComputeHash(Encoding.[Default].GetBytes(pass))
            Dim sb As New StringBuilder()
            For i As Integer = 0 To dataMd5.Length - 1
                sb.AppendFormat("{0:x2}", dataMd5(i))
            Next
            Return sb.ToString()
        End Function

        Public Shared Function HttpGet(ByVal URI As String) As String
            Dim req As System.Net.WebRequest = System.Net.WebRequest.Create(URI)
            'req.Proxy = New System.Net.WebProxy(ProxyString, True)
            'true means no proxy
            Dim resp As System.Net.WebResponse = req.GetResponse()
            Dim sr As New System.IO.StreamReader(resp.GetResponseStream())
            Return sr.ReadToEnd().Trim()
        End Function
    End Class
End Class

So, I call class in ASPX files and job done.

I make URL for last point and call for DBGrid using XML as below.

       Dim myDataSet As New DataSet
        myDataSet.ReadXml(UrlString1)
        Dim dv As DataView = New DataView(myDataSet.Tables(2))

        Datagrid1.DataSource = dv
        Datagrid1.DataBind()

Bye.

So Administrator please close this Issue.

Regards,
Nayeem.

0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
asp.net open new page without popup blocker 8 39
Adding items to a C# list incrementally 5 64
reading excel file in .net 2 32
Securing WEBAPI on Azure 2 27
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question