Solved

User Authentication and Read XML from URL in ASP.NET

Posted on 2009-05-06
1
303 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
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

856 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