Code here
let link = "https://api.yelp.com/oauth2/token"
guard let url = URL(string: link) else { return }
// Headers
let headers = [
"content-type": "application/x-www-form-urlencoded"
]
guard let clientID = infoPlist(withKey: "YELP_API_CLIENT_ID"),
let clientSecret = infoPlist(withKey: "YELP_API_CLIENT_SECRET") else { return }
let body = "client_id=\(clientID)&client_secret=\(clientSecret)&grant_type=client_credentials"
var request = URLRequest.init(url: url)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = body.data(using: .utf8)
As far as I know this should be working. Based on everything I've read this is the proper process for authenticating with Yelp Fusion/v3.
You didn't post your entire code, but with some slight modifications your code works: