I need some help, i try to get instagram api in my application( windows forms) but not success.My code is 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 run this give me the error:
{
"code": 400,
"error_type": "OAuthException",
"error_message": "This client is not xAuth enabled"
}
From the description of the error the values you are passing in for
data["client_id"]
anddata["client_secret"]
are not authorized to use the API. Make sure you have registered your application and you are using the correct two values that where given to you during your registration.Also check that your app is authorized to use
data["grant_type"] = "password";
. From reading their API password based authentication is not allowed, you must use "redirect based" authentications to be able to authenticate with their API.EDIT: Found this in the documentation under Step 3 for server side authentication
So your grant type of
password
and passing the username and password is definitely the problem.