0
私は、IGドキュメントの例でサーバ側の認証を実現しようとしていますが、問題が発生します。 私がリクエストをしているときに、状態302のレスポンスを得ました。ヘッダーの場所にコードで新しいリダイレクトURLがありませんでしたが、ブラウザで同じことをしてもOKです。ここでInstagram apiサーバ側認証asp.net mvc
は私のコードと例です:
public JsonResult InstagramTeaser()
{
try
{
var clientId = Configuration.AuthKeys.InstagramOAuthClientId;
var clientSecret = Configuration.AuthKeys.InstagramOAuthClientSecret;
var redirectUrl = "http://localhost";
var uri = $"http://api.instagram.com/oauth/authorize/?client_id={clientId}&redirect_uri={redirectUrl}&response_type=code";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.AllowAutoRedirect = false;
string redirUrl = String.Empty;
using (HttpWebResponse response = (HttpWebResponse) request.GetResponse())
{
int status = (int)response.StatusCode; // 302 Found
redirUrl = response.Headers[HttpResponseHeader.Location]; // And here I'm getting my old uri
}
return Json(redirUrl, JsonRequestBehavior.AllowGet);
}
catch (Exception e)
{
return Json(e.Message, JsonRequestBehavior.AllowGet);
}
}