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.

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

报告相同问题?

悬赏问题

  • ¥15 fluent的在模拟压强时使用希望得到一些建议
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退