Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

unable to add authorization header in Link #270

Open
naikdp7 opened this issue Mar 15, 2021 · 4 comments
Open

unable to add authorization header in Link #270

naikdp7 opened this issue Mar 15, 2021 · 4 comments
Labels
question Further information is requested

Comments

@naikdp7
Copy link

naikdp7 commented Mar 15, 2021

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 naikdp7 added the bug Something isn't working label Mar 15, 2021
@comigor comigor added question Further information is requested and removed bug Something isn't working labels Mar 22, 2021
@comigor
Copy link
Owner

comigor commented Mar 22, 2021

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.

@matehat
Copy link

matehat commented Mar 24, 2021

Somewhat related to #73. This comment specifically.

@moseskarunia
Copy link

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

@vasilich6107
Copy link
Collaborator

@naikdp7 do you still have issues with that?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

5 participants