即使令牌是正确的,Reddit GET也会返回403

时间:2016-12-22 16:30:05

标签: c# xamarin.android httpwebrequest reddit

我尝试与Reddit API进行交互,但在检索到我的access_token后遇到了GET上的一些问题。我已确认令牌和必需的范围来完成此操作:

        Android.Widget.Toast.MakeText(this, "TOKEN : " + myItem.myAccessKey.accessKeyString, ToastLength.Long).Show();
        HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create("https://www.reddit.com/api/v1/me");
        myRequest.PreAuthenticate = true;
        myRequest.Headers.Add("Authorization", "Bearer " + myItem.myAccessKey.accessKeyString);
        var myResponse = myRequest.GetResponse(); //403 forbidden here
        if (myResponse == null)
        {
            Finish();
        }
        var myStreamReader = new StreamReader(myResponse.GetResponseStream());
        var json = myStreamReader.ReadToEnd();
        myResponse.Close();
        myStreamReader.Close();

1 个答案:

答案 0 :(得分:0)

403表示禁止。身份验证成功,即令牌和标头正确,但您无权获取您输入的网址,package autotioficial; import java.io.File; import com.jacob.com.LibraryLoader; import autoitx4java.AutoItX; public class App { public static void main(String[] args) { File file = new File("lib", "jacob-1.18-x86.dll"); //path to the jacob dll System.setProperty(LibraryLoader.JACOB_DLL_PATH, file.getAbsolutePath()); AutoItX x = new AutoItX(); x.run("C:/Program Files (x86)/Internet Explorer/iexplore.exe"); } }