'Invalid auth token (98)' Uploading videos from Asp.net Application

Topics: Developer Forum
Jul 12, 2011 at 6:19 PM

I am attempting to allow user to upload videos to Flickr from an Asp.net application using the FlickrNet library/API. I've obtained an API key and an API secret from Flickr. Additionally I am retrieving an authToken using the AuthGetFrob method from the FlickrNet library.

My Using Statements are as Follows

using System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
FlickrNet;

I have created two methods to accomplish this task.

One which gets and returns the AuthToken

private string GetAuthenticateToken()
{
   
Flickr flickr = new Flickr(FLICKR_API_KEY, FLICKR_API_SECRET);

   
string frob = flickr.AuthGetFrob();

   
return flickr.AuthCalcUrl(frob, AuthLevel.Write);
}

And One the Uploads the File Using that AuthToken

public void UploadFile(string fileName, string title, string description)
{
   
try
   
{

       
string authToken = GetAuthenticateToken();

       
Flickr flickr = new Flickr(FLICKR_API_KEY, FLICKR_API_SECRET, authToken);


       
string photoId = flickr.UploadPicture(fileName, title, description, "", true, false, false);
       
}
   
catch (Exception ex)
   
{
       
throw ex;
   
}
}

However, when I make the call to 'UploadPicture' the following exception is thrown. 'Invalid auth token (98)'.

The contents of the AuthRequest Http request looks like this.

<?xml version="1.0" encoding="utf-8" ?>
<rsp stat="ok">
<frob>72157627073829842-9d8e31b9dcf41ea1-162888</frob>
</rsp>

And the content of the Upload methods Http request looks like this.

<?xml version="1.0" encoding="utf-8" ?>
<rsp stat="fail">
   
<err code="98" msg="Invalid auth token" />
</rsp>

I saw a similar post on the flickr forums here but based on my understanding, it appears that I am doing everything right yet still cannot figure what I am doing wrong.

Any help would be greatly appreciated.

Coordinator
Jul 13, 2011 at 7:14 AM

Hi

AuthCalcUrl returns a URL, not the actual authentication token. Also that is more for desktop authentication, rather than web based authentication. The forum post you link to is talking about Mobile authentication.

For web authentication you need to follow the flow detailed here: http://www.flickr.com/services/api/auth.howto.web.html

So you call Flickr.AuthCalcWebUrl, and then redirect the user to that URL.

Then when they have authenticated they will get sent to the Callback URL set up in your API key settings. This URL will include a frob.

Then finally in the callback url web page you get the frob from the querystring and call Flickr.AuthGetToken(frob);

If you want to see this in action then download the example ASP.Net web site from the example page.

Sam