API Request - Parse Authentication Token #6791
Replies: 1 comment 4 replies
-
To extract the authentication token from the JSON response in the current version of the codebase, you can use the
Here's a code snippet demonstrating how to use the from langflow.schema import Data
from langflow.components.processing.parse_json_data import ParseJSONDataComponent
# Example JSON response
json_response = '{"user_id": "1234567", "principal_id": "gfgfdgfsjgfskgdfgdf", "tenant_id": "435436625625", "tenant_name": "Co Company", "token": "eyJraWQGciOiJSUzUxMiIsInR5cCI6IkpXVCJ9.ey...", "json_web_token": "eyJraWQGciOiJSUzUxMiIsInR5cCI6IkpXVCJ9.ey..."}'
# Create an instance of the ParseJSONDataComponent
parser = ParseJSONDataComponent()
# Set the input value and query
parser.input_value = Data(data=json_response)
parser.query = ".token"
# Extract the 'token' field
filtered_data = parser.filter_data()
# Print the extracted token
for data in filtered_data:
print(data.data) # This should output the token value Regarding the renaming of activities, the To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other |
Beta Was this translation helpful? Give feedback.
-
I am very confused and need some help. :(
I need to make a Web API Request to retrieve data from a different system. For this, I need to make an "authenticate" API Request first, which will get me the bearer authentication token.
How do I extract this authentication token from the data output of the first API Request?
Output:
{
user_id: "1234567"
principal_id: "gfgfdgfsjgfskgdfgdf"
tenant_id: "435436625625"
tenant_name: "Co Company"
token: "eyJraWQGciOiJSUzUxMiIsInR5cCI6IkpXVCJ9.ey..."
json_web_token: "eyJraWQGciOiJSUzUxMiIsInR5cCI6IkpXVCJ9.ey..."
}
Also, the fact items continuously keep getting renamed is somewhat frustrating. I understand why this is needed at times, but it is just confusing. For instance, I am running v1.1.4 now, and there is no longer a Parse JSON activity. Where did it go or what did it move to?
Thanks everyone!
Beta Was this translation helpful? Give feedback.
All reactions