0

Yahoo Mail Api Not Working

Hi,

My httprequest looks like this

https://api.login.yahoo.com/oauth/v2/get_re...hoo%2fAuth.aspx

but i was getting an 401 exception

Can Anyone please help with this i was checking from the site itself

the code is like this

Dim OAuthBase As New OAuth.OAuthBase
Dim objStreamReader As System.IO.StreamReader = Nothing
Dim objStream As System.IO.Stream = Nothing
Dim strResult As String
Dim strTokenSecret As String
Dim strToken As String


'step 1 in Oauth is to get a request token. The OAUTHConsumerKey and OAUTHConsumerSecret must be your own. If you don't already have one,
'go to https://developer.apps.yahoo.com/dashboard/createKey.html and sign up for one.
'Then update the web config with your OAUTHConsumerKey and OAUTHConsumerSecret
'Also, it is really important that you specify the correct application url when signing up. Yahoo! will not allow oauth_callback to a domain that is different from your application url domain.
'Make sure you update the OAUTHCallbackURL to whatever domain you created your key with plus /auth.aspx (e.g., http://my.domain.com/auth.aspx)
'Also, please be sure that when you set up your key that you ask for read/write access to Yahoo! Mail and Yahoo! Contacts. If you don't then your credentials
'won't work for this example.

Dim strRequest As String = System.Configuration.ConfigurationManager.AppSettings("OAUTHGetRequestTokenURL") & _
"oauth_nonce=" & OAuthBase.GenerateNonce & _
"&oauth_timestamp=" & OAuthBase.GenerateTimeStamp & _
"&oauth_consumer_key=" & System.Configuration.ConfigurationManager.AppSettings("OAUTHConsumerKey") & _
"&oauth_signature_method=plaintext" & _
"&oauth_signature=" & System.Configuration.ConfigurationManager.AppSettings("OAUTHConsumerSecret") & "%26" & _
"&oauth_version=1.0" & _
"&oauth_callback=" & UrlEncode(System.Configuration.ConfigurationManager.AppSettings("OAUTHCallbackURL")) 'this variable indcates the url that the user will be redirected to after authenticating

'all we are doing here is creating an http get and passing in our oauth variables to get a request token
Dim objHTTPRequest As HttpWebRequest
Dim objHTTPResponse As HttpWebResponse

objHTTPRequest = CType(WebRequest.Create(strRequest), HttpWebRequest)
objHTTPRequest.Method = "GET"
objHTTPResponse = CType(objHTTPRequest.GetResponse(), HttpWebResponse)
objStream = objHTTPResponse.GetResponseStream()
objStreamReader = New System.IO.StreamReader(objStream)

'read the results from our http get
strResult = objStreamReader.ReadToEnd

'use regex to get our token and secret for the request token
strToken = getToken(strResult)
strTokenSecret = getTokenSecret(strResult)

Session("oauth_token_secret") = strTokenSecret

objStreamReader.Close()
objStream.Close()
objHTTPResponse.Close()

'now we actually redirect the user to the auth token url. This is the page hosted by yahoo that will ask the user to enter their password and confirm they want to link their account.
strRequest = System.Configuration.ConfigurationManager.AppSettings("OAUTHGetRequestAuthURL") & "oauth_token=" & strToken
Response.Redirect(strRequest)

thanx,

Pruthvi

by
5 Replies
  • Hi Pruthvi,

    Can you please provide the complete HTTP request and response headers
    so we can check where it may go wrong? You can leave out the consumer
    secret and token secret.

    In your other posts, I don't see the oauth_consumer_key in your request.

    Thanks,
    Yu Wang
    Yahoo! Membership Team
    0
  • hi,

    Below is the request i am sending

    CODEBOX
     https://api.login.yahoo.com/oauth/v2/get_request_token?oauth_nonce=8110415&oauth_timestamp=1284543499&oauth_consumer_key=&oauth_signature_method=plaintext&oauth_signature=1fc854b71ab4d70a41d028fd073a5842214558bc%26&oauth_version=1.0&oauth_callback=http%3a%2f%2fwww.wap.tigo.cd%2fyahoo%2fAuth.aspx



    i am getting the return response as

    The remote server returned an error: (401) Unauthorized

    Thanks ,
    Pruthvi


    QUOTE (omiga @ Sep 14 2010, 11:30 PM) <{POST_SNAPBACK}>
    Hi Pruthvi,

    Can you please provide the complete HTTP request and response headers
    so we can check where it may go wrong? You can leave out the consumer
    secret and token secret.

    In your other posts, I don't see the oauth_consumer_key in your request.

    Thanks,
    Yu Wang
    Yahoo! Membership Team
    0
  • I don't see oauth_consumer_key in your request.
    0
  • CODEBOX
    https://api.login.yahoo.com/oauth/v2/get_request_token?oauth_nonce=9584828&oauth_timestamp=1284636883&oauth_consumer_key=dj0yJmk9RmF3ZWExUzJ3blFGJmQ9WVdrOWFERnBhelpOTjJzbWNHbzlOR
    EkyT1RFd05qWXkmcz1jb25zdW1lcnNlY3JldCZ4PTYz&oauth_signature_method=plaintext&oauth_signature=1fc854b71ab4d70a41d028fd073a5842214558bc%26&oauth_version=1.0&oauth_callback=http%3a%2f%2fwww.wap.tigo.cd%2fyahoo%2fAuth.aspx



    the corrected link is here

    thanx ,

    Pruthvi
    0
  • Hi Pruthvi,

    Please change oauth_callback URL in your request to http://wap.tigo.cd/yahoo/Auth.aspx
    and try again. The callback host should match what you provided when you initially
    registered the application.

    Thanks,
    Yu Wang
    0

Recent Posts

in OAuth General Discussion YDN SDKs