The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

Hi all!

I am trying to get authorization in my Spotify account to retrieve some data with no success (new to Godot and programming).

According to the official example (
curl -X "POST" -H "Authorization: Basic ZjM4ZjAw...WY0MzE=" -d grant_type=client_credentials


   "access_token": "NgCXRKc...MzYjw",
   "token_type": "bearer",
   "expires_in": 3600,

In Godot, I got the following code (GDScript, based on official example on docs (

extends CanvasLayer

func _ready():
    pass # Replace with function body.

func _on_Button_pressed():
    var url : String = ""
    var headers = ["Authorization: Basic ZjM4ZjAw...WY0MzE="]
    var data_fields : Dictionary = {"grant_type" : "client_credentials"}
    var http : HTTPClient =
    var data : String = http.query_string_from_dict(data_fields)

    $HTTPRequest_POST.request(url, headers, true, HTTPClient.METHOD_POST, data)


func _on_HTTPRequest_POST_request_completed(result, response_code, headers, body):
    if result == HTTPRequest.RESULT_SUCCESS:
        if response_code == 200:
            print("http Error")

And console output is:
[Authorization: Basic ZjM4ZjAw...WY0MzE=]
http Error



[date: Fri, 26 Mar 2021 22:36:15 GMT, content-type: text/html; charset=utf-8, set-cookie: __Host-device_id=AQBoU23xYfSZOVf_AhBs6ky_5JVHvFuNma2JrEIQ1vhm8Bx9wxaFP2TjIzJ4EY7Ga7wF09wMDJCevmShdOzXzjiaFqcKchGQ5Ak;Version=1;Path=/;Max-Age=2147483647;Secure;HttpOnly;SameSite=Lax, content-security-policy: default-src 'self'; script-src 'self'; img-src 'self' https://* https://* data:; font-src 'self' data:; style-src 'self' 'unsafe-inline'; frame-src 'self' itms-apps:; connect-src 'self';, x-content-security-policy: default-src 'self'; script-src 'self'; img-src 'self' https://* https://* data:; font-src 'self' data:; style-src 'self' 'unsafe-inline'; frame-src 'self' itms-apps:; connect-src 'self';, sp-trace-id: db6ec545a42cc4a5, strict-transport-security: max-age=31536000, x-content-type-options: nosniff, content-encoding: gzip, vary: Accept-Encoding, server: envoy, Via: HTTP/2 edgeproxy, 1.1 google, Alt-Svc: clear, Transfer-Encoding: chunked]

<!DOCTYPE html>
<html ng-app="accounts" ng-csp>
    <meta charset="utf-8">
    <title>Error - Spotify</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <base href="/">
    <link rel="icon" href="">
    <link href="" media="screen" rel="stylesheet">
  <div class="head">
    <a class="spotify-logo" href="/" tabindex="-1" title="Spotify"></a>

    <div class="container-fluid error">
      <div class="content">
        <h1 class="h1">Error</h1>
          Oops! Something went wrong, please try again or check out our <a href="">help area</a>.
    <script async defer src="" sp-error=''></script>

I tested in Godot 4.0 as well as in Godot 3.2.3 with the same result.

How can I translate curl request over to a Godot script?

Godot version & 3.2.3
in Engine by (12 points)
recategorized by

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.