I have a problem with PhotobucketNet user login(I need user to login so I can upload a picture from HDD to his Photobucket account).
Photobucket photobucket = new Photobucket("myapikey", "myapisecret");
photobucket.LaunchUserLogin();
// the problem happens here
photobucket.RequestUserToken();
If I call RequestUserToken() it will happen immediately, so I'll get a crash cause user didn't logged in, and there is no event that's been raised after user logs in. Is there some variable(bool or something else) that I can check to see if user logged in - maybe to put it in a loop with timer? Also is their a way to know if user canceled logging in? I know that timer isn't a good solution, so if anyone has anything better as an idea, I'm open for any suggestions...
I've encountered the same problem today and i found your post while i was searching for solutions. Here is how i managed to solve the problem:
Firstly, i got the "user login url" and passed it to a form with a web browser control, called "Login".
Service=new Photobucket ("mykey", "mysecret");
string u=Service.GenerateUserLoginUrl ();
Login l=new Login (u);
l.Show ();
Next, I got the url from this page,
which is the page after the login. If the web browser's url is that page, i asked the photobucket class (in my case Program.Service), to request the token.
The code from the Login form is something like this:
public Login (string url)
{
InitializeComponent ();
webBrowser1.Navigate (url);
webBrowser1.DocumentCompleted+=delegate
{
if (webBrowser1.Url.ToString ()=="http://photobucket.com/apilogin/done")
{
PhotobucketNet.UserToken t=Program.Service.RequestUserToken ();
//save the token
}
}
}
Now you just save the token and use it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.