src/SmugMug.NET/Authentication/SmugMugAuthorize.cs
/// <summary>
/// Use this method to authorize the application to SmugMug.
/// </summary>
Use this method to authorize the application to SmugMug.
Use this method to authorize the application to SmugMug .
public static OAuthToken AuthorizeSmugMug(string apiKey, string secret, AuthenticationOptions options)
        {
            OAuth.OAuthAuthenticator authenticator = new OAuth.OAuthAuthenticator(apiKey, secret);
            string reqTokUrl = authenticator.CreateGetRequestTokenAddress(OAuthGetRequestTokenUrl, HttpMethod.Get.ToString(), NonWebOAuthApplicationCallback);
            string tokens = GetResponseContent(reqTokUrl).Result; 
            string authorizationOptions = options == null ? string.Empty : "?" + options.AsQueryString();
            string authorizeUrl = authenticator.CreateAuthorizeAddress(OAuthAuthorizeUrl + authorizationOptions, tokens);
            ProcessStartInfo psi = new ProcessStartInfo();
            psi.UseShellExecute = true; 
            psi.FileName = authorizeUrl;
            Process.Start(psi);
            Console.WriteLine("Press [Enter] after you authorized the application and entered the pin provided");
            string pin = Console.ReadLine();
            string reqToken, reqTokenSecret;
            authenticator.ParseRequestTokens(tokens, out reqToken, out reqTokenSecret);
            string accessTokenUrl = authenticator.CreateGetAccessTokenAddress(OAuthGetAccessTokenUrl, "GET", reqTokenSecret, reqToken, pin);
            string authTokens = GetResponseContent(accessTokenUrl).Result;
            string authToken, authTokenSecret;
            authenticator.ParseRequestTokens(authTokens, out authToken, out authTokenSecret);
            return new OAuthToken(apiKey, secret, authToken, authTokenSecret);
        }
public static OAuthToken AuthorizeSmugMug ( string apiKey , string secret , AuthenticationOptions options ) { OAuth . OAuthAuthenticator authenticator = new OAuth . OAuthAuthenticator ( apiKey , secret ) ; string reqTokUrl = authenticator . CreateGetRequestTokenAddress ( OAuthGetRequestTokenUrl , HttpMethod . Get . ToString ( ) , NonWebOAuthApplicationCallback ) ; string tokens = GetResponseContent ( reqTokUrl ) . Result ; string authorizationOptions = options == null ? string . Empty : " " + options . AsQueryString ( ) ; string authorizeUrl = authenticator . CreateAuthorizeAddress ( OAuthAuthorizeUrl + authorizationOptions , tokens ) ; ProcessStartInfo psi = new ProcessStartInfo ( ) ; psi . UseShellExecute = true ; psi . FileName = authorizeUrl ; Process . Start ( psi ) ; Console . WriteLine ( " " ) ; string pin = Console . ReadLine ( ) ; string reqToken , reqTokenSecret ; authenticator . ParseRequestTokens ( tokens , out reqToken , out reqTokenSecret ) ; string accessTokenUrl = authenticator . CreateGetAccessTokenAddress ( OAuthGetAccessTokenUrl , " " , reqTokenSecret , reqToken , pin ) ; string authTokens = GetResponseContent ( accessTokenUrl ) . Result ; string authToken , authTokenSecret ; authenticator . ParseRequestTokens ( authTokens , out authToken , out authTokenSecret ) ; return new OAuthToken ( apiKey , secret , authToken , authTokenSecret ) ; }
Use this method to authorize the application to SmugMug.
Use this method to authorize the application to SmugMug .
// requestClient.GetAsync(reqTokUrl).Result.Content.ReadAsStringAsync().Result; // Figure out which authorization options are requested (if any) // Launching the url to authorize the app // we need to be explicit about this since on Core the default is 'false' // Get the request token to exchange for an access token
apiKey
string
secret
string
options
AuthenticationOptions