Is refresh token mandatory for TD Ameritrade API?

915 Views Asked by At

I'm trying to use this Java library for TD Ameritrade https://github.com/studerw/td-ameritrade-client

Here is the starting code

    Properties props = new Properties();
    props.setProperty("tda.client_id", "[email protected]"); // I have this 
    props.setProperty("tda.token.refresh", "XXX");  // I don't have this 

I have a client_id, a.k.a. consumer key

But I don't have a refresh token. I only want to use the Quotes API, I don't want to make any actual trades. I'm able to test the consumer key here https://developer.tdameritrade.com/quotes/apis/get/marketdata/quotes and it works great. Do I have to obtain refresh token too? Is it mandatory? Is there any way to use consumer key only without the refresh token?

Here https://developer.tdameritrade.com/quotes/apis/get/marketdata/quotes it says "Authorization Token aka Refresh token is Optional", so is it really "Optional"

1

There are 1 best solutions below

0
On

As far as I can tell, if you have tokens, you will get more up to date quotes. If you do not, you will get delayed data:

Pass your OAuth User ID to make an unauthenticated request for delayed data.

If you want more realtime data (I do not have an Ameritrade account, not sure exactly what the delay difference is), you can use tokens:

(Optional) The Authorization token to validate the request. Not required for un-authenticated requests

(Un-authenticated requests being the above delayed route)

Alternatively, if you want a Refresh Token, which expires every 90 days and is used to gain an Access Token (expires every 30 minutes), the steps are listed here: https://developer.tdameritrade.com/content/simple-auth-local-apps

That will give you a refresh token that you can use for 90 days to request access tokens and allow you to authenticate without needing a server. Note that you will need to update your app's refresh token at least once every 90 days to keep it functioning.

Again, I do not have a TD Ameritrade account to personally confirm this, but looks like you have at least two options to get Quotes.

Further FAQ resources: