Try to get the instagram API

I need help, I am trying to get the instagram api in my application (windows forms) but not successful. My code looks like this:

using (var wb = new WebClient())
{
    var data = new NameValueCollection();
    data["client_id"] = "client_id"; 
    data["client_secret"] = "client_secret";
    data["username"] = "user"
    data["password"] = "pass"
    data["grant_type"] = "password";
    var response = wb.UploadValues("https://api.instagram.com/oauth/access_token", "POST", data);
    string json = System.Text.Encoding.ASCII.GetString(response);

      

But after running, give me error:

{
"code": 400,
"error_type": "OAuthException",
"error_message": "This client is not xAuth enabled"
}

      

+3


source to share


1 answer


From the error description, the values ​​you pass for data["client_id"]

and data["client_secret"]

are not allowed to use the API. Make sure you have your application registered and that you are using the correct two values ​​given to you during registration.

Also make sure your application is eligible to use data["grant_type"] = "password";

. From reading their API password based authentication is not allowed, you must use redirect based authentication to be able to authenticate with your API.

EDIT: Found this in the documentation for Step 3 for Server Side Authentication



grant_type: authorization_code is currently the only supported value

So your grant type password

and passing username and password is definitely a problem.

+1


source







All Articles