Search code examples
curlstocktwits

authenticating user to stocktwits


searching for a method to get access_token for single user. Looks like API Documentation says that its possible to authenticate user and get access_token via single curl request:

cURL [ about cURL ]
// Token example
curl -X GET -u <username> -p https://api.stocktwits.com/api/2/oauth/authorize -d 'client_id=<client id>&response_type=token&redirect_uri=http://www.example.com&scope=read,watch_lists,publish_messages,publish_watch_lists,follow_users,follow_stocks'

// Code example
curl -X GET https://api.stocktwits.com/api/2/oauth/authorize -d 'client_id=<client id>&response_type=code&redirect_uri=http://www.example.com&scope=read,watch_lists,publish_messages,publish_watch_lists,follow_users,follow_stocks'

But tried several attempts providing Username and Password using Token Example, but stocktwits looks to be redirecting to Login page. Was this functionality removed or im making a mistake somewhere?


Solution

  • Looks to be a misinterpretation of the docs. You cannot obtain the access token through requests yourself. The docs state

    Your application requests authorization by redirecting your user to https://api.stocktwits.com/api/2/oauth/authorize with your client_id, response_type set to 'code' and the URL the user should be redirected back to after the authorization process (redirect_uri). Scopes can also be passed (scope) in a comma-delimited list to request further permissions. View the authorize call. Enter the following URL into your browser or direct your users to it for authentication:

    Your users enter their credentials on the provided form after directing them to the url. Please see https://stocktwits.com/developers/docs/authentication