src/SmugMug.NET/Authentication/ConsoleAuthentication.cs
/// <summary>
/// Use the ITokenProvider to retrieved stored credentials. If they are not available, authorize with SmugMug using the console.
/// </summary>
Use the ITokenProvider to retrieved stored credentials. If they are not available, authorize with SmugMug using the console.
Use the ITokenProvider to retrieved stored credentials . If they are not available authorize with SmugMug using the console .
public static OAuthToken GetOAuthTokenFromProvider(ITokenProvider provider)
        {
            OAuthToken oauthToken = default(OAuthToken);
            if (!provider.TryGetCredentials(out oauthToken))
            {
                Console.WriteLine("Please enter your API Key and press [Enter]:");
                string apiKey = Console.ReadLine();
                Console.WriteLine("Please enter your Application Secret and press [Enter]:");
                string secret = Console.ReadLine();
                oauthToken = SmugMugAuthorize.AuthorizeSmugMug(apiKey, secret, AuthenticationOptions.FullAccess);
                provider.SaveCredentials(oauthToken);
            }
#if DEBUG
            Debug.WriteLine(string.Format("Using APIKey={0}", oauthToken.ApiKey));
            Debug.WriteLine(string.Format("Using AppSecret={0}", oauthToken.Secret));
            Debug.WriteLine(string.Format("Using token={0}", oauthToken.Token));
            Debug.WriteLine(string.Format("Using tokenSecret={0}", oauthToken.TokenSecret));
#endif
            return oauthToken;
        }
public static OAuthToken GetOAuthTokenFromProvider ( ITokenProvider provider ) { OAuthToken oauthToken = default ( OAuthToken ) ; if ( ! provider . TryGetCredentials ( out oauthToken ) ) { Console . WriteLine ( " " ) ; string apiKey = Console . ReadLine ( ) ; Console . WriteLine ( " " ) ; string secret = Console . ReadLine ( ) ; oauthToken = SmugMugAuthorize . AuthorizeSmugMug ( apiKey , secret , AuthenticationOptions . FullAccess ) ; provider . SaveCredentials ( oauthToken ) ; } if DEBUG Debug . WriteLine ( string . Format ( " " , oauthToken . ApiKey ) ) ; Debug . WriteLine ( string . Format ( " " , oauthToken . Secret ) ) ; Debug . WriteLine ( string . Format ( " " , oauthToken . Token ) ) ; Debug . WriteLine ( string . Format ( " " , oauthToken . TokenSecret ) ) ; endif return oauthToken ; }
Use the ITokenProvider to retrieved stored credentials.
Use the ITokenProvider to retrieved stored credentials .
// Do we have the secret/apikey?
provider
ITokenProvider