const Login = () => { const setToken = function(e) { if ( e.origin === origin && e.data && e.data.command === 'token-ready' && e.data.info && e.data.info.token ) { localStorage.setItem('jwt', e.data.info.token); e.source.postMessage( { command: 'info', info: { complete: true, }, }, e.origin ); } }; window.addEventListener('message', setToken, false); const login = () => { window.open(loginUri); }; return (<button onClick={login}>Login</button> }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter