Solved

User Authentication and Read XML from URL in ASP.NET

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

910 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now