Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using a third party OAuth API in Vapor

I am learning Vapor, and as part of this process I am building a website using the framework. As part of my application, I would like to make use of the Uber API which makes use of OAuth.

The process of retrieving a User Access Token as outlined here and it specifically recommends making use of a pre-built library to preform the authorization grant and token exchanges.

For OAuth, I was able to find two libraries, being:

OAuthSwift and p2/OAuth2

Both libraries don't seem to be compatible with Swift's Package Manager though and as a result, can't be used with Vapor.

Is there any work around to this? Or would I have to manually create a library to support the OAuth process with Vapor?

like image 630
maldahleh Avatar asked May 24 '18 21:05

maldahleh


1 Answers

From what I've seen most authentication in Vapor is done with turnstile: https://github.com/stormpath/Turnstile

There is good tutorial / walkthrough from raywenderlich: https://videos.raywenderlich.com/screencasts/637-server-side-swift-with-vapor-authentication-with-turnstile

Since you want to integrate with Uber, I suggest reading up on Uber's SDK for authentication and adding your own methods for handling the user endpoints, that way you can add Uber as a provider rather than adding an entirely new OAuth library / framework to do it for you.

Another great resource is Vapor OAuth, its beautifully written but a bit more technical: https://github.com/brokenhandsio/vapor-oauth

If you are new web development I suggest learning a well known framework such as React or Angular with Node.js before learning Vapor or have some native swift experience under your belt before continuing. React and Angular are Javascript based web frameworks that you can very easily get help with. React also supports iOS development with React Native and is used far more often than Vapor.

like image 142
RLoniello Avatar answered Oct 03 '22 05:10

RLoniello