artemis
artemis copied to clipboard
unable to add authorization header in Link
1)i have created one class which extends the Link 2)when my token is valid i have concat my customLink class with HttpLink(where i have set the uri and my header) 3)now while executing the request my server throws error of unAuthentication(token expired) 4)i have successfully refreshed my token 5)i want my current request(step3) to be executed with new token 6)for that i have to set my headers in my customLink class
i have tried below code
request.context.updateEntry((_)=>HttpLinkHeaders(headers: <String, String>{
'Authorization': "Bearer ${new-token}"
}));
Any help or guidance will be appreciated..thanks in advance
Hey @naikdp7!
Artemis currently uses gql's Link
as its underlining client mechanism. If you're changing/chaining new Links at runtime, you need to reinstantiate ArtemisClient.fromLink
.
Somewhat related to #73. This comment specifically.
ArtemisClient client({required FirebaseAuth firebaseAuth}) =>
ArtemisClient.fromLink(
AuthLink(
getToken: () async {
final token = await firebaseAuth.currentUser?.getIdToken();
return token;
},
).concat(
HttpLink(...),
),
);
@naikdp7 do you still have issues with that?