I am trying to get the public token passed into my server (built in python flask). But I keep getting:
BadRequestKeyError: 400 Bad Request: The browser (or proxy) sent a request that this server could not understand.
KeyError: 'public_token'
Here is my frontend written in jQuery:
onSuccess: async function(public_token, metadata) {
      // 2a. Send the public_token to your app server.
      // The onSuccess function is called when the user has successfully
      // authenticated and selected an account to use.
      await fetch('/get_access_token', {
        method: 'POST',
        body: JSON.stringify({ public_token: public_token }),
      });
    },
And the function that has problems in flask:
@app.route("/get_access_token", methods=['POST'])
def get_access_token():
  global access_token
  global item_id
  public_token = request.form['public_token']
  print(public_token)
  exchange_response = \
       client.Item.public_token.exchange(public_token)
  # Store the access_token and item_id in your database
  access_token = exchange_response['access_token']
  item_id = exchange_response['item_id']
  return jsonify(exchange_response)
