Jignesh Gohel
Jignesh Gohel

Reputation: 6552

OmniAuth/OAuth Authentication from a ruby script

Is there a way I can test out the OmniAuth authentication from a standalone ruby script? Every resource I could find on web lists its usage only in Rails project.This link too: http://www.omniauth.org/

In other words I could not find any client like this FitGem. The fitbit API uses Oauth authentication.FitGem is a client inteface to test out the authentication/authorization to FitBit using OAuth token. More details here on FitGem: http://www.fitbitclient.com/guide/getting-started

Thanks.

Upvotes: 3

Views: 435

Answers (1)

ryanc
ryanc

Reputation: 185

I realize this is old, but I came across it whilst googling so others might also. Maybe this will help the next passerby...

To answer the question - no, it isn't possible to use OmniAuth within a simple, standalone script. What froderik said is correct, OmniAuth was designed to be used within an app on a rack-based framework (Rails, Sinatra, Pakyow, etc.).

To expand on that just a bit though, OmniAuth relies on the ability to intercept and send HTTP requests to/from your app. By default, OmniAuth intercepts requests to /auth/:provider to kickoff the authorization process and will then send callbacks to either /auth/:provider/callback or /auth/failure depending on the outcome of the auth attempt.

Obviously, that functionality is beyond the scope of a standalone script. But if I were to recommend a solution for writing a quick test using OmniAuth, I'd recommend Sinatra. It's certainly not the only solution (any rack-based framework will do), but it provides the needed functionality with minimal overhead.

Upvotes: 2

Related Questions