Simplify your registration and sign-in process by using a "Connect with Stocktwits" button.
This lets your user know that they can register for your app with one click using their Stocktwits account. It also grants your app access to their account and gives you the ability to post messages and access their profile details. As mentioned in the Authentication documentation, your access to users' account details will vary depending on the user permissions that are granted upon signing up.
https://api.stocktwits.com/api/2/oauth/authorize?client_id=&response_type=code&redirect_uri=http://www.example.com&scope=read,watch_lists,publish_messages,publish_watch_lists,direct_messages,follow_users,follow_stocks
https://api.stocktwits.com/api/2/oauth/authorize?client_id=&response_type=code&redirect_uri=http://www.example.com&scope=read,watch_lists,publish_messages,publish_watch_lists,direct_messages,follow_users,follow_stocks
{ "user_id": 1, "access_token": "<access_token>", "scope": "read", "username": "userabc" }
The following JavaScript code is an example of implementing the signin process on the client-side:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js" type="text/javascript"></script> <script language="javascript"> $(document).on('click', '#connect', function() { window.open($(this).attr('href'), 'stocktwits_oauth', 'width=500,height=550'); return false; }); $(document).ready(function() { if (/access_token=(\w+)/.test(window.location.hash)) { var accessToken = window.location.hash.match(/access_token=(\w+)/)[1]; $.getJSON("https://api.stocktwits.com/api/2/account/verify.json?callback=?", { access_token: accessToken }, function(data) { if (data.user) { $('#me').html("Hello: " + data.user.username); } }); } }); </script> <a id="connect" href="https://api.stocktwits.com/api/2/oauth/authorize?client_id=<CLIENT ID GOES HERE>&redirect_uri=<REDIRECT URL>&response_type=token">Connect to Stocktwits</a> <div id="me"></div>