artemis icon indicating copy to clipboard operation
artemis copied to clipboard

unable to add authorization header in Link

Open naikdp7 opened this issue 3 years ago • 4 comments

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

naikdp7 avatar Mar 15 '21 19:03 naikdp7

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.

comigor avatar Mar 22 '21 16:03 comigor

Somewhat related to #73. This comment specifically.

matehat avatar Mar 24 '21 17:03 matehat

  ArtemisClient client({required FirebaseAuth firebaseAuth}) =>
      ArtemisClient.fromLink(
        AuthLink(
          getToken: () async {
            final token = await firebaseAuth.currentUser?.getIdToken();
            return token;
          },
        ).concat(
          HttpLink(...),
        ),
      );

moseskarunia avatar Sep 29 '21 19:09 moseskarunia

@naikdp7 do you still have issues with that?

vasilich6107 avatar Mar 30 '22 16:03 vasilich6107