1

I'm trying to access the instagramm api using the instasharp nuget package. Now I've been checking the github readme, to get some further informations.

Link: https://github.com/InstaSharp/InstaSharp

So I started to store the keys inside my app.config like the following:

<appSettings>
    <add key="client_id" value="xxx"/>
    <add key="client_secret" value="xxx "/>
    <add key="redirect_uri" value="xxx"/>
</appSettings>

And added a webbrowser to my winfoms project. This would be user to let the user authentificate their account with my application.

Now I've planned once the application is started, the Form1_Load event should get the link to the oauth site and navigate the browser to it.

My current code:

using InstaSharp;
using System;
using System.Configuration;
using System.Windows.Forms;

namespace Insta_Buddy
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void bunifuImageButton1_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void bunifuImageButton2_Click(object sender, EventArgs e)
        {
            this.WindowState = FormWindowState.Minimized;
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            var clientId = ConfigurationManager.AppSettings["client_id"];
            var clientSecret = ConfigurationManager.AppSettings["client_secret"];
            var redirectUri = ConfigurationManager.AppSettings["redirect_uri"];
            var realtimeUri = "";

            InstagramConfig config = new InstagramConfig(clientId, clientSecret, redirectUri, realtimeUri);
        }

    }
}

But now I'm kind of confused, how to continue since Instasharp tells me to add the following code:

public ActionResult Login()
{
    var scopes = new List<OAuth.Scope>();
    scopes.Add(InstaSharp.OAuth.Scope.Likes);
    scopes.Add(InstaSharp.OAuth.Scope.Comments);

    var link = InstaSharp.OAuth.AuthLink(config.OAuthUri + "authorize", config.ClientId, config.RedirectUri, scopes, InstaSharp.OAuth.ResponseType.Code);

    return Redirect(link);
}

But I think this isn't winforms based, since ActionResult can't be called. And I need the link from this application to navigate the webbrowser there to authentificate the user.

Does anyone have a idea or created something similare to this?

I really appreciate any kind help.

d45ndx
  • 89
  • 8

0 Answers0