Comments (5)
I'm pretty sure that the OauthInterceptor only generates a new refresh token upon an explicit failure (401 error). That initiates the code to create a refresh token, and then once a new auth token is obtained, it will never be required to generate it until either the app class is destroyed (which means the auth token is lost) or it times out on the server side, which shouldn't happen unless your client doesn't make a call for X minutes.
Can you write an integration test, where the client makes numerous API calls (get 10 quotes or something like that) and turn on the OAuth logging? If we grep that log, I think we'll see that only one auth token is ever generated.
from td-ameritrade-client.
Hi,
Look at this code in OauthInterceptor below:
//This gets updated using the refresh code - the first call will always fail, forcing a
//new access_token to be set.
private String accessToken = "UNSET";
public OauthInterceptor(HttpTdaClient client, Properties properties) {
this.client = client;
this.properties = properties;
}
@Override
public Response intercept(Chain chain) throws IOException {
Request authorizedRequest = chain.request().newBuilder()
.addHeader("Authorization", "Bearer " + this.accessToken)
.build();
Response origResponse = chain.proceed(authorizedRequest);
As you can see you're always setting "Authorization" to "Bearer UNSET".
For example you can see this by using your MainExample example class. In this class make 2 calls to the fetchQuotes API method and set TRACE on in OauthInterceptor if needed. You'll see that a new access_token is being generated on the 2nd call.
Sincerely
from td-ameritrade-client.
I was thinking about this code some more today on a car ride this afternoon and it dawned on me that I think you wanted to cache the accessToken for the life cycle of HttpTdaClient. If so I think this is a defect.
from td-ameritrade-client.
from td-ameritrade-client.
You're right. This was my mistake. I now see that this class does indeed cache the access_token and reuse it.
Sorry for any confusion. Please close this issue.
from td-ameritrade-client.
Related Issues (20)
- Option Prices: repeated error on NAN instead of valid double HOT 4
- FYI See this repo with clean TD Ameritrade API schemas. HOT 1
- Option Chain Parse failure from getOptionChain() HOT 7
- Duplicate class / NoSuchMethodError HOT 1
- PlaceOrder question HOT 2
- placeOrder HOT 1
- New issue with retrieving transaction history HOT 5
- Orders failed to parse. HOT 2
- Getting Error while creating Option order HOT 1
- Fetching Child Order Price HOT 1
- fix javadoc HOT 2
- Create Option Order - OptionInstrument sending null/blank values
- Generating a new access token with every API call HOT 2
- when do you implements Streaming API function? HOT 1
- RuntimeException: Empty json body: [200 - ] - https://api.tdameritrade.com/v1/marketdata/quotes?symbol=blahblah1 HOT 1
- Vulnerabilities from dependencies HOT 1
- Java code giving error HOT 3
- Receiving unauthorized errors when calling API and 400 status when trying to get access token HOT 2
- Using Spring and getting javax.validation.NoProviderFoundException with PriceHistReq Validation
- Schwab API HOT 14
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from td-ameritrade-client.