dsideal2015 2017-02-17 17:45
浏览 100
已采纳

尝试检索个人资料信息时,linkedin登录返回404

I have an app on linkedin that uses the login api. It is a web app that makes use of go and the goth authentication library. Up until a few days ago my app was authenticating users fine. Now it returns this error message:

linkedin responded with a 404 trying to fetch user information

The app has been running continuously without updates for weeks. So there hasn't been any code changes.

I should mention that it does bring me to the login page but after entering my username and password it redirects and outputs the aforementioned error

The goth oauth api code is located here: https://github.com/markbates/goth/blob/master/providers/linkedin/linkedin.go

It essentially calls this url with the access token http://api.linkedin.com/v1/people/~:(id,first-name,last-name,headline,location:(name),picture-url,email-address)

Does anyone know if the api endpoints have changed or any other reason authentication would just stop working?

I've been checking the blog but I see no updates in regards to the api and there doesn't seem to be a way to reach linkedin developer support as it just points to stackoverflow.

  • 写回答

2条回答 默认 最新

  • doudunyi3796 2017-02-18 20:35
    关注

    So after digging deeper into this issue. It seems that linkedin is now returning http 2.0 responses from their api.

    I discovered this by writing a small go program which I ran on my local machine and on the aws instance where the server code is located.

    package main
    
    import (
        "fmt"
        "io/ioutil"
        "net/http"
        "net/http/httputil"
        "net/url"
    )
    
    const (
        bearerToken string = "AQVJampuUSuvWs5beuCvHiJYC--"
    )
    
    func main() {
    
        userEndpoint := "//api.linkedin.com/v1/people/~:(id,first-  name,last-name,headline,location:(name),picture-url,email-address)?format=json"
    
    client := &http.Client{}
    
    req, err := http.NewRequest("GET", "", nil)
    
    req.URL = &url.URL{
        Scheme: "https",
        Host:   "api.linkedin.com",
        Opaque: userEndpoint,
    }
    
    req.Header.Set("Authorization", "Bearer "+bearerToken)
    resp, err := client.Do(req)
    
    request, _ := httputil.DumpRequest(req, true)
    
    fmt.Println("request:", string(request))
    
    data, _ := ioutil.ReadAll(resp.Body)
    
    response, _ := httputil.DumpResponse(resp, false)
    
    resp.Body.Close()
    
    fmt.Println("response:", string(response))
    
    fmt.Println(err, req.URL.String(), string(data))
    }
    

    When running this on my local machine the api returned a response with the profile data. When I ran it on the aws instance it returned a 404 with an http 2.0 header

    Here is an excerpt of the output of running this program on aws

    request: GET https://api.linkedin.com/v1/people/~?format=json HTTP/1.1 Host: api.linkedin.com Authorization: Bearer AQVJampuUSuvWs5beu--

    response: HTTP/2.0 404 Not Found Content-Length: 5530 Cache-Control: no-store Content-Language: en Content-Type: text/html Date: Sat, 18 Feb 2017 03:45:21 GMT X-Li-Pop: prod-lva1-h2

    <!-- EF of static content included-->
    <html>
      <head>
      <title>404: Not Found</title>
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <style type="text/css">
     /* GLOBAL */
    

    Now I don't know if this a bug or expected behaviour but it appears that linkedin is returning http 2.0 responses when go is picking up causing the 404.

    They way I was able to fix it was to turn off http 2.0 client support in go itself. By setting the following environment variable

    GODEBUG=http2client=0

    At which point the linkedin api returns the profile information.

    I'm curious to know if this is a bug with linkedin or go. Hopefully someone from linkedin can chime in.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题