title: Could not parse the ephemeral key response following protocol
body: <p>I am trying to create an ephemeral key in my IOS app. I can successfully create a stripe customer that saves in my firebase console and on my stripe dashboard. However, when I try to create the ephemeral key, I am receiving the error in my ios console after trying to view the checkout controller.</p>
  <blockquote>
  <p>'Could not parse the ephemeral key response following protocol STPCustomerEphemeralKeyProvider. Make sure your backend is sending the unmodified JSON of the ephemeral key to your app.</p>
  </blockquote>
  <p>and on my firebase function logs I am seeing,</p>
  <blockquote>
  <p>createEphemeralKey
  Request has incorrect Content-Type.</p>
  </blockquote>
  <blockquote>
  <p>createEphemeralKey
  Invalid request, unable to process.</p>
  </blockquote>
  <p>in my index.js file, the code that I am using is</p>
  <pre><code>exports.createEphemeralKey = functions.https.onCall(async(data, context) =&gt; {
    var stripeVersion = data.api_version;
    const customerId = data.customer_id;
  
    return stripe.ephemeralKeys.create(
      {customer: customerId},
      {stripe_version: stripeVersion}
    ).then((key) =&gt; {
      return key
    }).catch((err) =&gt; {
      console.log(err)
    })
  })
  </code></pre>
  <p>Below is how I create my stripe customer.</p>
  <pre><code>    exports.createStripeCustomer = functions.auth.user().onCreate((user) =&gt; {
    return stripe.customers.create({
      email: user.email,
    }).then((customer) =&gt; {
      return admin.database().ref(`/stripe_customers/${user.uid}/customer_id`).set(customer.id);
    });
  });
  </code></pre>
  <p>and then myAPIClient looks like.</p>
  <pre><code>    enum APIError: Error {
       case unknown
  
       var localizedDescription: String {
           switch self {
           case .unknown:
               return &quot;Unknown error&quot;
           }
       }
   }
  
  static let sharedClient = MyAPIClient()
  var baseURLString: String? = &quot;https://myProject.cloudfunctions.net/&quot;
  var baseURL: URL {
      if let urlString = self.baseURLString, let url = URL(string: urlString) {
          return url
      } else {
          fatalError()
      }
  }
  
     func createCustomerKey(withAPIVersion apiVersion: String, completion: @escaping STPJSONResponseCompletionBlock) {
      let url = self.baseURL.appendingPathComponent(&quot;ephemeral_keys&quot;)
      Alamofire.request(url, method: .post, parameters: [
          &quot;api_version&quot;: apiVersion,
          ])
          .validate(statusCode: 200..&lt;300)
          .responseJSON { responseJSON in
              switch responseJSON.result {
              case .success(let json):
                  completion(json as? [String: AnyObject], nil)
              case .failure(let error):
                  completion(nil, error)
              }
      }
  }
  </code></pre>
  <p>On my checkOutVC, I have</p>
  <pre><code>var stripePublishableKey = &quot;pk_test_testProjectKey&quot;
  var backendBaseURL: String? = &quot;https://myProject.cloudfunctions.net&quot;
  
          let customerContext = STPCustomerContext(keyProvider: MyAPIClient())
  
      init(price: Int, settings: Settings) {
          
          if let stripePublishableKey = UserDefaults.standard.string(forKey: &quot;StripePublishableKey&quot;) {
              self.stripePublishableKey = stripePublishableKey
          }
          if let backendBaseURL = UserDefaults.standard.string(forKey: &quot;StripeBackendBaseURL&quot;) {
              self.backendBaseURL = backendBaseURL
          }
          let stripePublishableKey = self.stripePublishableKey
          let backendBaseURL = self.backendBaseURL
          
          assert(stripePublishableKey.hasPrefix(&quot;pk_&quot;), &quot;You must set your Stripe publishable key at the top of acceptWorker.swift to run this app.&quot;)
          assert(backendBaseURL != nil, &quot;You must set your backend base url at the top of acceptWorker.swift to run this app.&quot;)
          
          Stripe.setDefaultPublishableKey(self.stripePublishableKey)
          let config = STPPaymentConfiguration.shared()
          config.appleMerchantIdentifier = self.appleMerchantID
          config.companyName = self.companyName
          config.requiredBillingAddressFields = settings.requiredBillingAddressFields
          config.requiredShippingAddressFields = settings.requiredShippingAddressFields
          config.shippingType = settings.shippingType
          config.additionalPaymentOptions = settings.additionalPaymentOptions
          config.cardScanningEnabled = true
          self.country = settings.country
          self.paymentCurrency = settings.currency
          
          self.theme = settings.theme
          MyAPIClient.sharedClient.baseURLString = self.backendBaseURL
    
          let paymentContext = STPPaymentContext(customerContext: customerContext, configuration: config, theme: settings.theme)
          self.paymentContext = STPPaymentContext(customerContext: customerContext)
          super.init(nibName: nil, bundle: nil)
          self.paymentContext.delegate = self
          self.paymentContext.hostViewController = self
          self.paymentContext.paymentAmount = 5000 // This is in cents, i.e. $50 USD
  
      }
  
      required init?(coder: NSCoder) {
          fatalError(&quot;init(coder:) has not been implemented&quot;)
      }
  </code></pre>
  <p>I apologize for the long lines of code but I am really running into a brick wall. Why isnt the backend creating the ephemeralKey for customers?</p>