AuthenticationModules may be called by the user. In general the login method will pass tokens to a server and parse the response for any necessary keys. Logout will remove the tokens locally and call any necessary server methods. enroll will pass a user’s information to a remote service and create an account. These tasks are often implementation specific. We do have modules supporting HttpBasic and HttpDigest as part of the AeroGear framework.

AbstractAuthenticationModule is a convenience class for integrating with non AeroGear REST services. It is also useful for when you want to only support a subset of the AuthenticationModule's functionality, and it configures a THREAD_POOL_EXECUTOR for you to delegate your network calls to.

Using Authentication: Custom Applications

AeroGear Android's Authentication API provides a framework for supporting many other RESTful services. Obviously this guide cannot cover all of them, but we will review custom authentication with one third party service, Reddit.

To retrieve the tokens Reddit requires for accessing a user's data we must log in as that user. Reddit's login service consumes a HTTP POST at the URL http://www.reddit.com/api/login/%username with the Content-Type of application/x-www-form-urlencoded. The request body is required to also include the parameters user, passwd, and api_type. It returns a JSON response with parameters "json.data.modhash" and "json.data.cookie". These parameters are extracted as part of the login method and passed to the Pipe implementation from the getAuthorizationFields method.

Every Pipe request against the Reddit service from now on, will include these authorisation parameters as part of the request.