Forum Discussion
Anonymous
2 years agoNot applicable
Pull data fromAPI with token from multiple query, each one invalidate each other's token
I have a dataflow with multiple queries ( i have 8 queries) that are getting data from a third party API. Each query call the get_token() function at the beggining and stores it in a variable to use...
- Anonymous2 years ago
For clarity, I will write the full solution here
aj1973 provided a clue to get to my solution. in this link https://www.youtube.com/watch?v=2RZkc_qrV1g&t=610s
What I need was :
- get a access_token to be generated once and stored in order to be used by the other queries.
- do not expose that token outside of those queries
What I could not do :
- have a function that request the token and call that function in each subsequent queries because each call would generate a new accesstoken and invalidate the previous one.
Solution :
- create a queries that results in a 1 row, 1 column table with the accesstoken.
- Uncheck the "enable load" on that query
this prevent this token to be accessible outside the queries and will not be accessible by anyone consulting the resulting data
- Doesn't required premium, if you leave it check, it will be consider a premium feature
- Then in each of the query that needs that token, you can get that token like this: Table.FirstValue(get_tokenQuery)
Each time a query ask for that value from that table, if that table is empty, the get_tokenQuery will run and then return the result, if the get_tokenQuery has already ran, it will simply return the token but will not generate a new token. Thus all the query can run simultaneously with the same token
Success.
Anonymous
2 years agoNot applicable
For clarity, I will write the full solution here
aj1973 provided a clue to get to my solution. in this link https://www.youtube.com/watch?v=2RZkc_qrV1g&t=610s
What I need was :
- get a access_token to be generated once and stored in order to be used by the other queries.
- do not expose that token outside of those queries
What I could not do :
- have a function that request the token and call that function in each subsequent queries because each call would generate a new accesstoken and invalidate the previous one.
Solution :
- create a queries that results in a 1 row, 1 column table with the accesstoken.
- Uncheck the "enable load" on that query
this prevent this token to be accessible outside the queries and will not be accessible by anyone consulting the resulting data
- Doesn't required premium, if you leave it check, it will be consider a premium feature
- Then in each of the query that needs that token, you can get that token like this: Table.FirstValue(get_tokenQuery)
Each time a query ask for that value from that table, if that table is empty, the get_tokenQuery will run and then return the result, if the get_tokenQuery has already ran, it will simply return the token but will not generate a new token. Thus all the query can run simultaneously with the same token
Success.