cancel
Showing results for 
Search instead for 
Did you mean: 

Making GET subscription API call with Golang http wrapper client

gnunez06
Level 2

I am trying to make a GET subscription API call using a simple Go program. However, it's not working as expected. 

 

 

 

package main

import (
    "net/http"
    "strings"
    "log"
    "io/ioutil"
)

func main() {
  x := "access_token=OC|<redacted>|<redacted>"
  body := strings.NewReader(x)
  req, err := http.NewRequest(
    "GET",
    "https://graph.oculus.com/application/subscriptions",
    body,
  )
  if err != nil {
  	// handle err
  }
  resp, err := http.DefaultClient.Do(req)
  if err != nil {
  	// handle err
  }
  defer resp.Body.Close()
  respBody, err := ioutil.ReadAll(resp.Body)
  if err != nil {
      log.Fatal(err)
  }
  log.Println(string(respBody))
}

 

 

 

Error that I see:

 

 

2022/02/09 16:43:16 {"error":{"message":"Invalid OAuth 2.0 Access Token","type":"OCApiException","code":190,"error_data":{},"fbtrace_id":"AUtKko-oyk08x89VogGw-2_"}}

 

 

 

I can make the request through curl successfully, as pointed out in the example here (https://developer.oculus.com/documentation/native/ps-subscriptions-s2s/)

0 REPLIES 0