UPLOADPICTURE ERROR Invalid auth token (98)

Topics: Developer Forum, Project Management Forum
May 6, 2014 at 9:27 PM
HI EVERYONE!

I am trying to upload a picture to my flickr account with flickr.net, but when I execute the following code :

__public static void uploadPhoto()
{
        Flickr flickr = new Flickr(ConfigurationManager.AppSettings["apiKey"],
           ConfigurationManager.AppSettings["shardSecret"]);
        OAuthRequestToken requestToken = flickr.OAuthGetRequestToken("oob");
        flickr.OAuthAccessTokenSecret = requestToken.TokenSecret;
        flickr.OAuthAccessToken = requestToken.Token;
        string FileuploadedID = flickr.UploadPicture(@"C:\Users\AlvaroUniversidad\Pictures\5maseldescuento.png", "TwittingRoom", "TwittingRoom Image", "", true, false, false);
}__

I get the error: "FlickrNet.Exceptions.LoginFailedInvalidTokenException: Invalid auth token (98)"

I don't know how to upload a picture with flickrnet, I need help Please!!!

Regards.

Alvaro Real.
Coordinator
May 6, 2014 at 9:29 PM
A oauth request token is not the same thing as an oauth access token. You must redirect the user to the Flickr web site to authenticate your application, and then use the verifier token, along with the request token to get the access token.

Check the sample apps here: https://flickrnetsamples.codeplex.com/

Sam
May 7, 2014 at 7:53 AM
So Sam;

I need to put in flickr.OAuthAccessToken the value I get when the user authenticate my application, ¿But I need flickr.OAuthAccessTokenSecret or not? And another question, ¿Where do i put the account's name to upload this picture to this account? Because when I display pictures from Flickr in my application I use the UserId, but to upload a picture I don't use it anywhere.

Alvaro Real.
Coordinator
May 7, 2014 at 8:34 AM
Yes, you need the access token and the access token secret. They are both returned by the OAuthGetAccessToken() method.

When you authenticate the access token IS your user credentials, so when you upload using that access token it uploads to the account of the user who that access token belongs to.

Sam
May 7, 2014 at 10:22 AM
I need to explain what I want to do; I would like to do an application where the final user chooses a picture and he uploads it to my personal Flickr account, so I do not want to show the user this page: "https://www.flickr.com/services/oauth/authorize?oauth_token=xxx&perms=read", because it will be always the same process. Can i do this authentication without displaying that page? I know of course my UserId, that will be always the same.

Alvaro Real
Coordinator
May 7, 2014 at 10:47 AM
You are only allowed to upload photos to your Flickr account if you own them and have the copyright for them. Doing otherwise is against the Flickr terms of service.

You cannot authenticate without going to that page, at least once. You can then store the access token and access token secret. However you should never distribute these values inside an application as they would then give anyone who could extract them full access to your Flickr account.

Sam
May 7, 2014 at 11:40 AM
Thank you very much Sam. You are being very helpful for me. I didn't know that about the copyright for pictures. I will ask for permissions before uploading pictures.

If I store the access token and access token secret, Do I always have authorization to upload photos to my account? or I need to authenticate every time I launch the application.

Alvaro Real.
Coordinator
May 7, 2014 at 1:12 PM
Once you've got the access token you don't need to authenticate again.

Sam
May 7, 2014 at 10:13 PM
Thank you very much Sam!! It worked!! :)

Alvaro Real