RxAuth


Source link: https://github.com/sebastianmarschall/RxAuth

RxAuth

Reactive Auth APIs Wrapper Library for Google's Smart Lock for Passwords API.

Usage

Build RxAuth object

val rxAuth = RxAuth.Builder(context).setPasswordLoginSupported(true).setAccountTypes(IdentityProviders.GOOGLE).build()

Retrieve Credentials

rxAuth.retrieveCredentials().subscribe({

  // use Credential to sign in into your app

}
, {

 if (it is StatusException) {

  if (it.status.hasResolution()) {

try {

 it.status.startResolutionForResult(activity, CREDENTIAL_REQUEST_RC)

}
 catch (e1: IntentSender.SendIntentException) {

 Log.e(TAG, "RxAuth: Failed to send resolution.")

}

}
 else {

 // The user must create an account or sign in manually.

 Log.e(TAG, "RxAuth: Unsuccessful credential request.");

  
}

 
}

}
)

Watch for a StatusException in the onError() callback. When the user has stored more than one Credential Status.hasResolution() returns true. In this case call startResolutionForResult() to prompt the user to choose an account. You will get the chosen credentials in the activity's onActivityResult() method by calling the retrieveCredentialFromIntent(Intent) method on the RxAuth object that you created:

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent) {

 super.onActivityResult(requestCode, resultCode, data)
 if (requestCode == CREDENTIAL_REQUEST_RC) {

  if (resultCode == RESULT_OK) {

rxAuth.retrieveCredentialFromIntent(data).subscribe({
 credentials ->

 // use Credential to sign in into your app

}
)

  
}

 
}
 
}

Store Credentials

rxAuth.storeCredentials(credential).subscribe({

Log.d(TAG, "stored credentials") 
}
, {

if (it is StatusException) {

 if (it.status.hasResolution()) {

  try {

it.status.startResolutionForResult(activity, CREDENTIAL_STORE_RC)

  
}
 catch (e1: IntentSender.SendIntentException) {

Log.e(TAG, "STATUS: Failed to send resolution.")

  
}

  
}

}
 
}
)

In case the credentials are new, the user must confirm the store request. Again watch for a StatusException in the onError() callback. Resolve the save request with startResolutionForResult() to prompt the user for confirmation. The activity's onActivityResult() notifies if the user confirmed the store request:

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent) {

 super.onActivityResult(requestCode, resultCode, data)
 if (requestCode == CREDENTIAL_STORE_RC) {

  if (resultCode == RESULT_OK) {

Log.d(TAG, "RxAuth: user stored credentials")

  
}
 else {

Log.d(TAG, "RxAuth: user canceled storing credentials")

  
}

 
}
 
}

Delete Credentials

rxAuth.deleteCredential(credential).subscribe({

 if(it) {

 // Credential has been deleted

 
}

}
,{

 Log.e(TAG, "RxAuth: error while deleting credentials")

}
)

Add RxAuth To Your Project

Add this to your build.gradle file:

dependencies {

compile 'com.sebastianmarschall:rxauth:0.3.1' 
}

Additional Notes

This library is strongly inspired by the RxSmartLock but is written in Kotlin and uses RxJava2.

License

Copyright 2017 Sebastian Marschall  Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 

Resources

Dali is an image blur library for Android. It is easy to use, fast and extensible. Dali contains several modules for either static blurring, live blurring and animations. It uses RenderScript internally (although different implementations can be chosen) and is heavily cached to be fast and keeps small memory footprint. It features a lot of additional image filters and may be easily extended and pretty every configuration can be changed.

Under the Hood is a flexible and powerful Android debug view library. It uses a modular template system that can be easily extended to your needs, although coming with many useful elements built-in.

There is a lot of "default" debug data that can be easily embedded (e.g. current runtime-permission status, app version and device info). There are 2 basic themes (dark and light) which can be customized to your needs.

Sticky header view or suspending view for RecyclerView. RecyclerStickyHeaderView is an Android library that makes it easy to integrate section headers stick to the top in RecyclerView.

Official Google Actions SDK is written in Node.js. But in many situations voice interfaces like Google Home or Google Assistant will extend or replace mobile apps. If you are old fashioned Android engineer and the most of your code is already written in Java, why not reuse it and build voice extension to app on your own? And this is the main reason to build Google Actions Java SDK - enabling as much developers as possible to build their brilliant ideas for Google Assistant and Home.

Currently this is just working proof of concept of Google Actions Java SDK. It means that there is no documentation, fixed interface, (not much) unit tests and many, many others.

Google Actions Java SDK is build based on official Node.js library, but it's not a mirror copy of it. The goal is to make it fully compatible with Conversational Protocol of Assistant Platform.

Applozic Android Video Calling SDK lets you integrate video call, audio call, real time chat and in-app messaging in just few lines of code.

A versatile layout that fades its edges regardless of child view type.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes