Help with authentication...

Topics: User Forum
Nov 6, 2006 at 2:11 AM
Hi, my website is trying to upload photos to flickr.
I have the APIKey and everything setup, however when I call the uploadpicture method for some reason it redirects me to the flickr login site... with a very long querystring...I was expecting flickr to send me the frob back (this only happens if I signin to flickr, once I signout i get this problem)

What am I doing wrong?

here is my code


MyAuth = MyFlickrAuth.AuthGetToken(frob)
MyToken = MyAuth.Token
Dim title As String = "test"
Dim description As String = "test"
Dim tags As String = "test"
Dim MyFlickr As New Flickr(ConfigurationManager.AppSettings.Get("FlickrEventAPIKey"), ConfigurationManager.AppSettings.Get("FlickrEventSharedSecret"), MyToken)
PhotoID = MyFlickr.UploadPicture(fileupImage.PostedFile.InputStream, title, description, tags, True, True, True)


Thanks
Coordinator
Nov 6, 2006 at 8:22 AM
None of the statements you include in the sample code contains a redirect - in fact there isn't a single redirect in the FlickNet code anywhere.

To authenticate a web application you need to redirect to the Flickr web site based on the URL returned by the AuthCalcWebUrl(frob, perms) method.

Let me know if that helps at all.

Sam
Nov 6, 2006 at 4:48 PM
Hi Sam, yes I am calling the AuthCalWebURL(permissions).
basically I have 2 pages.

one is called : postimage.aspx

in this one, I have this code:

Private MyFlickr As New Flickr(ConfigurationManager.AppSettings.Get("FlickrEventAPIKey"), ConfigurationManager.AppSettings.Get("FlickrEventSharedSecret"))

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim url As String = MyFlickr.AuthCalcWebUrl(AuthLevel.Delete)
Response.Redirect(url)

End Sub

          • According to the tutorial, AuthCalcWebUrl does not require frob because this is a web application.

Now, in my flickr settings my callbackurl is
uploadimage.aspx

In this page I have the following code:
uploadimage.aspx

Partial Class accounts_uploadimage
Inherits System.Web.UI.Page

Private PhotoID As Integer = 0
Private frob As String
Private MyAuth As Auth
Private MyToken As String
Private MyFlickrAuth As New Flickr(ConfigurationManager.AppSettings.Get("FlickrEventAPIKey"), ConfigurationManager.AppSettings.Get("FlickrEventSharedSecret"))

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Grab Frob
frob = Request.QueryString("frob")

End Sub


Protected Sub btnPostImage_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnPostImage.Click
'Image upload

MyAuth = MyFlickrAuth.AuthGetToken(frob)
MyToken = MyAuth.Token
Dim title As String = "test"
Dim description As String = "test"
Dim tags As String = "Test"
Dim MyFlickr As New Flickr(ConfigurationManager.AppSettings.Get("FlickrEventAPIKey"), ConfigurationManager.AppSettings.Get("FlickrEventSharedSecret"), MyToken)
PhotoID = MyFlickr.UploadPicture(fileupImage.PostedFile.InputStream, title, description, tags, True, True, True)

'Dim MyPhotoInfo As PhotoInfo
'MyPhotoInfo = MyFlickrAuth.PhotosGetInfo(photoid)
'Dim Mediumphotourl As String = MyPhotoInfo.MediumUrl
'Dim Smallphotourl As String = MyPhotoInfo.SmallUrl


End Sub
End Class

***Again, this redirects me to the flickr sign in page and in the query string it shows my apikey and all the info, but it does not redirect me back to the page I specified in the callbackurl


Please advise
Coordinator
Nov 6, 2006 at 9:15 PM
I'll look at this soon, but in the mean time can you check out the example web application I've uploaded and see if you are doing anything different.

Examples
Nov 7, 2006 at 3:57 AM
Hi Sam, I downloaded your web application replaced my api key, username and secret key but unfortunately I still get redirected to the Flickr login page.
Once I entered my username and password, I get automatically transfer to the Url that I specified in the CallbackURL where I can see my user name and the message "successfully authenticated".

Why do I need to mannually enter my user name and password?
I don't get it.

I appreciate your help!.
Coordinator
Nov 7, 2006 at 9:06 AM
You need to enter your username and password only if you are not logged into Flickr already. If you log into FLickr and set the "remember me" feature it will not ask you for your username/password the next time - in fact if you have already authenticated the application it simply sends you straight back to the callback url.

If you store the Auth.Token value in a cookie you can use this next time without having to redirect to Flickr at all.
Nov 7, 2006 at 9:54 AM
Thanks Sam, Stored the token in my web config

It worked.

You are the man!