{{ $authUrl := os.Getenv "HUGO_API_AUTH_URL" }}
{{ $gqlUrl := os.Getenv "HUGO_GQL_API_URL"}}
{{ $gqlUser := os.Getenv "HUGO_API_GQL_USER"}}
{{ $gqlPass := os.Getenv "HUGO_API_GQL_PASSWORD"}}
{{ $assetsUrl := os.Getenv "HUGO_API_ASSETS_URL"}}
{{ $token := "actualAccessToken" }}
{{ $bearer := printf "Bearer %s" $token }}
{{ $postsPayload := ( dict
"method" "POST"
"body" `{ "query": "{ posts { id title } }" }`
"headers" (dict
"Content-Type" "application/json"
"X-REQUEST-TYPE" "GraphQL"
"Authorization" $bearer
)
) }}
{{ with resources.GetRemote $gqlUrl $postsPayload }}
{{ with .Err }}
{{ warnf " %s" . }}
{{ else }}
{{ $rawData := unmarshal .Content }}
{{ $rawData }}
{{ end }}
{{ end }}
OUTPUT : WARN 2022/07/10 13:11:03 failed to fetch remote resource: Unauthorized
The same payload works with curl, vscode etc...
It seems the remote data was cached… passing --ignoreCache during build gave me new access tokens