|
| 1 | + |
| 2 | +<p>For more information on using Lock <a href="/libraries/lock">see the documentation.</a></p> |
| 3 | +<div class="code-picker"> |
| 4 | + <div class="languages-bar"> |
| 5 | + <ul> |
| 6 | + <li class="active"><a href="#lock-modal" data-toggle="tab">Lock (Modal)</a></li> |
| 7 | + <li><a href="#lock-inline" data-toggle="tab">Lock (Inline)</a></li> |
| 8 | + <li class="dropdown"><a href="#" data-toggle="dropdown">Passwordless</a> |
| 9 | + <ul class="dropdown-menu"> |
| 10 | + <li><a href="#passwordless-sms" data-toggle="tab">Passwordless (SMS)</a></li> |
| 11 | + <li><a href="#passwordless-magiclink" data-toggle="tab">Passwordless (Magic Link)</a></li> |
| 12 | + <li><a href="#passwordless-emailcode" data-toggle="tab">Passwordless (Email Code)</a></li> |
| 13 | + </ul> |
| 14 | + </li> |
| 15 | + <li><a href="#customui" data-toggle="tab">Custom UI</a></li> |
| 16 | + <li><a href="#plainlink" data-toggle="tab">Plain Links</a></li> |
| 17 | + </ul> |
| 18 | + </div> |
| 19 | + <div class="tab-content"> |
| 20 | + <div id="lock-modal" class="tab-pane active"> |
| 21 | + <pre class="hljs html"><code><script src="https://cdn.auth0.com/js/lock/10.2/lock.min.js"></script> |
| 22 | +<script> |
| 23 | + var lock = new Auth0Lock('${account.clientId}', '${account.namespace}', { |
| 24 | + auth: { |
| 25 | + redirectUrl: '${account.callback}', |
| 26 | + responseType: 'code', |
| 27 | + params: { |
| 28 | + scope: 'openid email' // Learn about scopes: https://auth0.com/docs/scopes |
| 29 | + } |
| 30 | + } |
| 31 | + }); |
| 32 | +</script> |
| 33 | +<button onclick="lock.show();">Login</button></code></pre> |
| 34 | + </div> |
| 35 | + <div id="lock-inline" class="tab-pane"> |
| 36 | + <pre class="hljs html"><code><div id="root" style="width: 320px; margin: 40px auto; padding: 10px; border-style: dashed; border-width: 1px; box-sizing: border-box;"> |
| 37 | + embedded area |
| 38 | +</div> |
| 39 | +<script src="https://cdn.auth0.com/js/lock/10.2/lock.min.js"></script> |
| 40 | +<script> |
| 41 | + var lock = new Auth0Lock('${account.clientId}', '${account.namespace}', { |
| 42 | + container: 'root', |
| 43 | + auth: { |
| 44 | + redirectUrl: '${account.callback}', |
| 45 | + responseType: 'code', |
| 46 | + params: { |
| 47 | + scope: 'openid email' // Learn about scopes: https://auth0.com/docs/scopes |
| 48 | + } |
| 49 | + } |
| 50 | + }); |
| 51 | + lock.show(); |
| 52 | +</script></code></pre> |
| 53 | + </div> |
| 54 | + <div id="passwordless-sms" class="tab-pane"> |
| 55 | + <pre class="hljs html"><code><script src="https://cdn.auth0.com/js/lock-passwordless-2.2.min.js"></script> |
| 56 | +<script> |
| 57 | + var lock = new Auth0LockPasswordless('${account.clientId}', '${account.namespace}'); |
| 58 | + function open() { |
| 59 | + lock.sms({ |
| 60 | + callbackURL: '${account.callback}', |
| 61 | + authParams: { |
| 62 | + scope: 'openid email' // Learn about scopes: https://auth0.com/docs/scopes |
| 63 | + } |
| 64 | + }); |
| 65 | + } |
| 66 | +</script> |
| 67 | +<button onclick="window.open();">SMS</button></code></pre> |
| 68 | + </div> |
| 69 | + <div id="passwordless-magiclink" class="tab-pane"> |
| 70 | + <pre class="hljs html"><code><script src="https://cdn.auth0.com/js/lock-passwordless-2.2.min.js"></script> |
| 71 | +<script> |
| 72 | + var lock = new Auth0LockPasswordless('${account.clientId}', '${account.namespace}'); |
| 73 | + function open() { |
| 74 | + lock.magiclink({ |
| 75 | + callbackURL: '${account.callback}', |
| 76 | + authParams: { |
| 77 | + scope: 'openid email' // Learn about scopes: https://auth0.com/docs/scopes |
| 78 | + } |
| 79 | + }); |
| 80 | + } |
| 81 | +</script> |
| 82 | +<button onclick="window.open();">Magic Link</button></code></pre> |
| 83 | + </div> |
| 84 | + <div id="passwordless-emailcode" class="tab-pane"> |
| 85 | + <pre class="hljs html"><code><script src="https://cdn.auth0.com/js/lock-passwordless-2.2.min.js"></script> |
| 86 | +<script> |
| 87 | + var lock = new Auth0LockPasswordless('${account.clientId}', '${account.namespace}'); |
| 88 | + function open() { |
| 89 | + lock.emailcode({ |
| 90 | + callbackURL: '${account.callback}', |
| 91 | + authParams: { |
| 92 | + scope: 'openid email' // Learn about scopes: https://auth0.com/docs/scopes |
| 93 | + } |
| 94 | + }); |
| 95 | + } |
| 96 | +</script> |
| 97 | +<button onclick="window.open();">Email Code</button></code></pre> |
| 98 | + </div> |
| 99 | + <div id="customui" class="tab-pane"> |
| 100 | + <pre class="hljs html"><code><button class="signin-google">Sign in with Google (redirect)</button><br> |
| 101 | +<button class="signin-google-popup">Sign in with Google (popup)</button><br> |
| 102 | +<br><p>--- or ---</p> |
| 103 | +<label>Email</label><input type="text" id="email"><br> |
| 104 | +<label>Password</label><input type="password" id="password"><br> |
| 105 | +<button class="signin-db">Sign in with Email/Password</button> |
| 106 | + |
| 107 | +<script src="https://cdn.auth0.com/w2/auth0-7.1.min.js"></script> |
| 108 | +<script src="http://code.jquery.com/jquery.js"></script> |
| 109 | +<script> |
| 110 | + var auth0 = new Auth0({ |
| 111 | + domain: '${account.namespace}', |
| 112 | + clientID: '${account.clientId}', |
| 113 | + callbackURL: '${account.callback}' |
| 114 | + }); |
| 115 | + // sign-in with social provider with plain redirect |
| 116 | + $('.signin-google').on('click', function() { |
| 117 | + auth0.signin({connection: 'google-oauth2'}); // use connection identifier |
| 118 | + }); |
| 119 | + // sign-in with social provider using a popup (window.open) |
| 120 | + $('.signin-google-popup').on('click', function() { |
| 121 | + auth0.signin({popup: true, connection: 'google-oauth2'}, |
| 122 | + function(err, profile, id_token, access_token, state) { |
| 123 | + /* |
| 124 | + store the profile and id_token in a cookie or local storage |
| 125 | + $.cookie('profile', profile); |
| 126 | + $.cookie('id_token', id_token); |
| 127 | + */ |
| 128 | + }); |
| 129 | + }); |
| 130 | + $('.signin-db').on('click', function() { |
| 131 | + auth0.signin({ |
| 132 | + connection: 'foo', |
| 133 | + username: 'bar', |
| 134 | + password: 'foobar' |
| 135 | + }, |
| 136 | + function (err, profile, id_token, access_token, state) { |
| 137 | + /* |
| 138 | + store the profile and id_token in a cookie or local storage |
| 139 | + $.cookie('profile', profile); |
| 140 | + $.cookie('id_token', id_token); |
| 141 | + */ |
| 142 | + }); |
| 143 | + }); |
| 144 | +</script></code></pre> |
| 145 | + </div> |
| 146 | + <div id="plainlink" class="tab-pane"> |
| 147 | + <pre class="hljs md"><code>https://${account.namespace}/authorize?response_type=code |
| 148 | + &scope=openid%20profile |
| 149 | + &client_id=${account.clientId} |
| 150 | + &redirect_uri=${account.callback} |
| 151 | + &connection=CONNECTION_NAME</code></pre> |
| 152 | + </div> |
| 153 | + </div> |
| 154 | +</div> |
0 commit comments