Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Mark Carrel
Mark Carrel
9,873 Points

Getting "Could not connect to the server." error in Swift tutorial on using OAuth with Yelp.

I'm working through the Swift tutorial on using OAuth with Yelp and am getting a, "Cannot connect to the server." error when the code executes the 'oauth.authorize' function. I've checked everything carefully and my code follows the tutorial example exactly as far as I can tell (except, of course, I use my own client ID and client secret codes for Yelp). I can connect to the server manually via a browser, so the server is reachable.

At this point, I'm not sure where else to look for the error. I'd really appreciate any suggestions on where to start looking for the problem. Thanks!

9 Answers

Jeff McDivitt
Jeff McDivitt
23,970 Points

I will take a look tonight. In the meantime, did you download the completed project from downloads and see if the code differs from yours in any way?

Jeff McDivitt
Jeff McDivitt
23,970 Points

Can you post your code on GitHub so I can see it?

Mark Carrel
Mark Carrel
9,873 Points

Yes, I've put the file here.

https://github.com/mcarrel/code-samples/blob/master/PermissionController.swift

I think the relevant portions are at the top where the oauth object is created and at the bottom where oauth.authorize is called. The rest of the code was pre-existing in the tutorial starter file treehouse provided for this project and is just setting up the view.

I appreciate any suggestions you might have - I'm totally lost as to what is going wrong. Thanks!

Jeff McDivitt
Jeff McDivitt
23,970 Points

Do you have the entire project?

Mark Carrel
Mark Carrel
9,873 Points

Yes, I just pushed it up on GitHub now.

https://github.com/mcarrel/oauthSampleProject

There's quite a few files, though

Jeff McDivitt
Jeff McDivitt
23,970 Points

I apologize I should have specified that the way to put entire projects on GitHub is to Zip them. That way myself or any other programmer can download the zip file and open it

Mark Carrel
Mark Carrel
9,873 Points

Sorry, I should have realized that (new to gitHub, too) - I've zipped the project and put it up here:

https://github.com/mcarrel/code-samples/blob/master/RestaurantReviews.zip

Mark Carrel
Mark Carrel
9,873 Points

Thanks, Jeff! Yes, I did down load the completed project but it I haven't been able to build it yet as I'm running into problems with dependencies in the project. I'm working with that now and will post if I make progress. Thanks again.

Mark Carrel
Mark Carrel
9,873 Points

Got it! Managed to sort out the problem with the dependencies and build the finished project to compare against my project. After all that, it turned out to be a typo in a dictionary key -- seems so obvious now. Thanks for your assistance!