示例#1
0
 public static IAuthContext AuthContextFromCredentials(InstagramCredentials credentials, string callbackUrl)
 {
     return(new AuthContext()
     {
         AuthorizationURL = GetAuthUrl(credentials, callbackUrl)
     });
 }
示例#2
0
 /// <summary>
 /// Get the authorization url.
 /// </summary>
 private static string GetAuthUrl(InstagramCredentials appCredentials, string callbackUrl)
 {
     return(String.Format("https://api.instagram.com/oauth/authorize/" +
                          "?client_id={0}" +
                          "&redirect_uri={1}" +
                          "&response_type=token", appCredentials.ClientID, callbackUrl) +
            "&scope=basic+public_content+follower_list+relationships+comments+likes");
 }
示例#3
0
        public static void Initialize(TestContext tcontext)
        {
            // Set credentials from client-ID
            InstagramCredentials instaCre = new InstagramCredentials("6a5985a97e0842d3a97c80d29a761f83");
            IAuthContext         context  = AuthFlow.InitAuth(instaCre, "http://www.google.es");

            var token = GetTokenFromUrl(context.AuthorizationURL, "<username>", "<password>");

            // Set the credentials
            AuthFlow.CreateCredentialsFromAccesToken(token);

            AuthFlow.SetUserCredentials();

            Assert.IsNotNull(UserManager.GetAuthenticatedUser());
        }
示例#4
0
 public InstagramHttpClient(IOptions <InstagramCredentials> appSettings, IHttpClientFactory clientFactory, ILogger <InstagramApi> logger)
 {
     _appSettings   = appSettings.Value;
     _clientFactory = clientFactory;
     _logger        = logger;
 }
示例#5
0
 /// <summary>
 /// Default constructor that takes in the dependencies that it needs to get configuration, logging and external http client calls
 /// </summary>
 /// <param name="appSettings">An instance of <see="InstagramCredentials" /></param>
 /// <param name="logger">An ILogger for this class</param>
 /// <param name="client">A <see="InstagramHttpClient" /> which wraps http calls </param>
 public InstagramApi(IOptions <InstagramCredentials> appSettings, ILogger <InstagramApi> logger, InstagramHttpClient client)
 {
     _appSettings = appSettings.Value;
     _logger      = logger;
     _client      = client;
 }