Is there a widget available or has some one worked on a widget that uses functionality from this JS sample
OAuth Basic | ArcGIS API for JavaScript
I think this place is much more better for your question:
Web AppBuilder Custom Widgets
Thanks... just moved the question there.