duanlongling5308 2016-07-11 16:49 采纳率: 0%
浏览 97
已采纳

当我尝试使用Instagram API连接到oauth2.0时,我从api.instagram.com收到400-错误结果。 为什么?

Here is my code in golang to connect to the instagram api

if resp, err := http.PostForm("https://api.instagram.com/oauth/access_token", url.Values{"client_secret": {appSecret}, "grant_type": {"authorization_code"},
        "redirect_uri": {redirectUri}, "client_id": {appId}, "code": {code},
    }); err == nil {
        log.Info("%s", resp)
    } else {
        return 500, ctr.ErrorResponse(500, err.Error())
    }

and when I print out my response, I get this

&{400 Bad Request %!s(int=400) HTTP/2.0 %!s(int=2) %!s(int=0) map[Content-Length:[114] Expires:[Sat, 01 Jan 2000 00:00:00 GMT] Vary:[Cookie, Accept-Language] Pragma:[no-cache] Cache-Control:[private, no-cache, no-store, must-revalidate] Set-Cookie:[csrftoken=gUnoNsIbM8edetUJO126sp28WZmC1BuO; expires=Mon, 10-Jul-2017 16:45:38 GMT; Max-Age=31449600; Path=/] Content-Language:[en] Date:[Mon, 11 Jul 2016 16:45:38 GMT] Content-Type:[application/json]] {%!s(*http.http2clientStream=&{0xc8201a6f20 0xc82017e380 1 0xc820a26b40 {{0 0} {0xc820d12160 {0 <nil> <nil>} 0 859544035736} 0xc82022e3f0 0xc82000a0e0 <nil> <nil> 0x1f3760} true {10485760 0xc8201a6f68} {4194190 0xc8201a6f78} 114 <nil> 0xc82000b280 0xc820a26ba0 <nil> 0xc820a26c00 true false map[] 0xc820dc6078})} %!s(int64=114) [] %!s(bool=false) map[] %!s(*http.Request=&{POST 0xc82040a180 HTTP/1.1 1 1 map[Content-Type:[application/x-www-form-urlencoded]] {0xc82043b820} 234 [] false api.instagram.com map[] map[] <nil> map[]   <nil> <nil>}) %!s(*tls.ConnectionState=&{771 true false 49199 h2 true  [0xc8201fcd80 0xc8201fd200] [[0xc8201fcd80 0xc8201fd200 0xc820b28900]] [] [] [203 149 65 158 231 245 216 167 215 32 166 255]})}

What's going on and how can I fix it?

  • 写回答

1条回答 默认 最新

  • doujiufutaog59220 2016-07-11 17:24
    关注

    Both the code I was passing in and the redirectURI were wrong. The redirectURI has to match the one used in the authorization step.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向