Solved

User Authentication and Read XML from URL in ASP.NET

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

760 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

20 Experts available now in Live!

Get 1:1 Help Now