An open API service indexing awesome lists of open source software.

https://github.com/khadkarajesh/auth

Authentication module
https://github.com/khadkarajesh/auth

android-architecture-components android-ktx android-library authentication kotlin-android kotlin-coroutines retrofit2 reusable-components

Last synced: about 1 year ago
JSON representation

Authentication module

Awesome Lists containing this project

README

          

# Auth
Authentication module

# Uses
Add in Application class

## Step 1
Add config on applcations ```onCreate()```
```
var endPoint = EndPoint.Builder()
.baseUrl("your_base_url")
.login("auth/authenticate")
.forgotPassword("password/reset")
.resetPassword("password/reset")
.build()
AuthConfig.setEndpoint(endPoint)
```
## Step 2
Register event to get response
```
EventBus.register(this)
```
Get Response as:
```
@Subscribe
fun onSuccess(event: AuthEvent) {
when (event) {
is LoginSuccess -> {
// your result
}
}
}
```

# Deserialize Response Body BaseResponse
```
class BaseResponse {
@SerializedName("body")
val body: R? = null
}
```

```
var gson = Gson()
var baseResponse: BaseResponse = Gson().fromJson(event.result.string(), gson.getType(BaseResponse::class.java, User::class.java))
Log.d("login success", "called " + baseResponse.body?.firstName)
this.startActivity(Intent(this, DashboardActivity::class.java))
```