CreateAuthorizationUrl() public method

Creates the Authorization Url, that the user will visit to allow your application to access their user account. For more information on how OAuth2 on Imgur works, visit their Developer Section (https://api.imgur.com/oauth2)
public CreateAuthorizationUrl ( OAuth2Type responseType, string state = null ) : string
responseType OAuth2Type /// The type of response you want to use. It's recomended that; /// - Pin: Desktop/Server/Mobile Applications /// - Code: Desktop/Server/Mobile Applications /// - Token: Javascript Applications ///
state string The state you want to pass through auth. This will be given back to you from the re-direct url if you use Code or Token Authentication.
return string
コード例 #1
0
		public async Task TestCodeAuth()
		{
			var settings = VariousFunctions.LoadTestSettings();

			// Create a new OAuth2 Authentication
			var oAuth2Authentication = new OAuth2Authentication(settings.ClientId, settings.ClientSecret, false);
			var authorizationUrl = oAuth2Authentication.CreateAuthorizationUrl(OAuth2Type.Code, "dicks");
			var code = "1234";
			try
			{
				await oAuth2Authentication.AuthorizeWithCode(code);
			}
			catch (ImgurResponseFailedException exception)
			{
				Assert.AreEqual(exception.ImgurResponse.Data.ErrorDescription, "Refresh token doesn't exist or is invalid for the client");
			}
		}
コード例 #2
0
		public async Task TestPinAuth()
		{
			var settings = VariousFunctions.LoadTestSettings();

			// Create a new OAuth2 Authentication
			var oAuth2Authentication = new OAuth2Authentication(settings.ClientId, settings.ClientSecret, false);
			var authorizationUrl = oAuth2Authentication.CreateAuthorizationUrl(OAuth2Type.Pin, "dicks");
			Assert.AreNotEqual("", authorizationUrl);
			var pin = "1234";
			try
			{
				await oAuth2Authentication.AuthorizeWithPin(pin);
			}
			catch (ImgurResponseFailedException exception)
			{
				Assert.AreEqual(exception.ImgurResponse.Data.ErrorDescription, "Invalid Pin");
			}
		}