YouTube API serie

Hi,

I’m doing the YouTube API Series but run into trouble in the second lesson. In the google API environment, I get a 200 code when I run it but in XCode, it get a 403 error, and I have no idea why. See below for the code. My API key is only missing, which is working in the YouTube API Test Area, at least so it seems.

import SwiftUI

struct ContentView: View {
var body: some View {
VStack {
Image(systemName: “globe”)
.imageScale(.large)
.foregroundStyle(.tint)
Text(“Hello, world!”)
}
.padding()
.task {
// Make the network call and print the results
// Define the endpoint url with parameters
let urlString = “https://youtube.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId=PLMRqhzcHGw1b7HFep9bJFc-a2a_1IustP&key=
// Create a URL instance
let url = URL(string: urlString)

        if let url = url {
            // Create URLRequest instance
            let request = URLRequest(url: url)
            
            do {
                // Send the request with URLSession
               let (data, response) = try await URLSession.shared.data(for: request)
            
                // Print out the response
                print(data)
                print(response)
            }
            catch {
                // Handle errors
                print(error)
            }
  
        }
    }
}

}

#Preview {
ContentView()
}