FlickrNet.Flickr.AuthGetToken C# (CSharp) Method

AuthGetToken() public method

After the user has authenticated your application on the flickr web site call this method with the FROB (either stored from AuthGetFrob or returned in the URL from the Flickr web site) to get the users token.
public AuthGetToken ( string frob ) : Auth
frob string The string containing the FROB.
return Auth
        public Auth AuthGetToken(string frob)
        {
            if( _sharedSecret == null ) throw new FlickrException(0, "AuthGetToken requires signing. Please supply api key and secret.");

            Hashtable parameters = new Hashtable();
            parameters.Add("method", "flickr.auth.getToken");
            parameters.Add("frob", frob);

            FlickrNet.Response response = GetResponseNoCache(parameters);
            if( response.Status == ResponseStatus.OK )
            {
                Auth auth = new Auth(response.AllElements[0]);
                return auth;
            }
            else
            {
                throw new FlickrException(response.Error);
            }
        }

Usage Example

Exemplo n.º 1
0
        public void Login()
        {
            // Create Flickr instance
            m_flickr = new Flickr(API_KEY, SECRET);

            m_frob = m_flickr.AuthGetFrob();

            string flickrUrl = m_flickr.AuthCalcUrl(m_frob, AuthLevel.Write);

            // The following line will load the URL in the users default browser.
            System.Diagnostics.Process.Start(flickrUrl);

            bool bIsAuthorized = false;
            m_auth = new Auth();

            // do nothing until flickr authorizes.
            while (!bIsAuthorized)
            {
                try
                {
                    m_auth = m_flickr.AuthGetToken(m_frob);
                    m_flickr.AuthToken = m_auth.Token;
                    bIsAuthorized = true;
                }
                catch (FlickrException ex)
                {
                    //TODO
                    string s = ex.Message;
                }
            }
        }
All Usage Examples Of FlickrNet.Flickr::AuthGetToken
Flickr