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.