Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Build a Restaurant Reviews App Authorization With Third Party Libraries Authorizing with the OAuth2 Framework

Hardik Pansuria
Hardik Pansuria
1,449 Points

Yelp doesn't OAuth token url anymore

To authenticate API calls with the API Key, set the Authorization HTTP header value as Bearer API_KEY. how to implement this instead of token url

1 Answer

Nathan F.
Nathan F.
30,773 Points

Hi Hardik, here's a simple implementation that you can adjust to your needs. You can get your API token from the 'Manage App' section of Yelp Developer's site. Pasan's aware of this change and there will likely be an update to reflect this soon.

let apiToken = "veryLongSecretAPIToken"
let bearerString = "Bearer \(apiToken)"

let endpointURL = URL(string: "https://api.yelp.com/v3/businesses/someBusiness")!
let yelpRequest = URLRequest(url: endpointURL)
yelpRequest.addValue(bearerString, forHTTPHeaderField: "Authorization")
Deysha Rivera
Deysha Rivera
5,088 Points

Thanks so much for this. Unfortunately, still no update to this video over a year later.