angular-oauthio

An angular wrapper around http://oauth.io
Homepage:
0 people use it

angular-oauth.io

https://oauth.io/ is a service that allows you to integrate in your app a lot of OAuth providers, without much hassle and keeping the secret keys away from your code.

However, it only handles the login until you get an access token, and then you are on your own.

angular-oauth.io was born to go a step further, allowing the developer to attach handlers that can exploit said token, by storing it, making api calls and whatever they want.

Getting Started

In your web page:

In your app.js file:

Configuration

Oauth.io needs a public key to work, and you can set it like this:

This is the bare minimum. Of course you may want to attach an handler for a certain provider:

Note that thanks to dependency injection you have access to other services inside your handler, which allows you to do nearly everything.

Documentation

The oauth.io module contains a OAuth provider, which does the wrapping, and a OAuthData service, which contains the latest result from your login attempts.

OAuthProvider

This provider can be used to setup the application with the oauth.io public key and to setup the handler for each authentication method you plan to use.

This method allows you to provide the Public Key you can get from https://oauth.io.

key should be a string (of course);

This method allows you to provide an handler for a certain authentication provider.

provider should be a string, and represent the provider which you want to connect.

handler should be a function which will be called once the user is authenticated. Thanks to the magic of dependency injection you can use whichever angular service you want inside it.

OAuth

This service can be used to fire the popup with the authentication.

provider should be a string, and represent the provider which you want to connect.

Of course when the popup authentication has been successful the handler for that provider will be called.

OauthData

This service can be used to retrieve the results of the authentication.

This object contain the results of the authentication, including access tokens and whatever.

It's most useful inside an handler.

Limitations

  • There is no safety net: who know what would happen if you provide bad input?
  • Only the popup method is wrapped.
  • Handlers are defined in the config stage. This means you have to use raw functions or angular constants, which is weird.

License

comments powered by Disqus
This page was last updated almost 3 years ago.