2

I am using Instasharp library to communicate with Instagram. After passing required parameters and building the link for authentication. System shows the screen that page not found (supposed to be Instagram Authentication Page for login)

My code is given below

*var client_id = ConfigurationManager.AppSettings["instagram.clientid"].ToString();
                var secret = ConfigurationManager.AppSettings["instagram.clientsecret"].ToString();
                var redirect_uri = ConfigurationManager.AppSettings["instagram.redirecturi"].ToString();
                var realtimeUri = "";
                var scopes = new List<OAuth.Scope>();
                scopes.Add(OAuth.Scope.Likes);
                scopes.Add(OAuth.Scope.Comments);
                var config = new InstagramConfig(client_id, secret, redirect_uri, realtimeUri);
                var oauth = new OAuth(config);
                var link = OAuth.AuthLink(config.OAuthUri + "/authorize", config.ClientId, config.RedirectUri, scopes, OAuth.ResponseType.Code);
                Response.Redirect(link);*

Please note that final value for variable link is given below

https://api.instagram.com/oauth//authorize?client_id=Client Id Goes Here&redirect_uri=Redirect URL goes here&response_type=code&scope=likes+comments

Once the application tries to redirect the page, it shows me the page not found error at instagram website. Please observe the picture given below

Instagram page not found

Please advise if anybody has experienced the similar situation before.

Shiva
  • 20,575
  • 14
  • 82
  • 112
Tiyyob
  • 89
  • 1
  • 12

1 Answers1

2

I experienced the same issue today when I tried to build a "Hello World" MVC5 Web Application using the Instasharp Library.

The Getting Started link on the project's home page seems outdated and has incorrect text and code in a few places, including the authenticate section (which is where your code is also failing).

I've raised an issue for this, and will work with the Project owner to update the documentation. Meanwhile, notice the extra slash in the link variable's value.

https://api.instagram.com/oauth//authorize...

The Problem

So here's the problematic line in your code.

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

The Fix

To fix this, remove the / in front of authorize in this line of code. The correct code for this line is as follows.

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

This worked for me. It took me to the Instagram login page. After I logged in, my Callback url ( which I had set to http://localhost:51524/Callback ) was instantly called with the code, which I then sent as a parameter to get the Oauth response.

Community
  • 1
  • 1
Shiva
  • 20,575
  • 14
  • 82
  • 112