Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update JWT token #251

Closed
Sigve84 opened this issue Jun 8, 2020 · 3 comments
Closed

Update JWT token #251

Sigve84 opened this issue Jun 8, 2020 · 3 comments
Labels

Comments

@Sigve84
Copy link

Sigve84 commented Jun 8, 2020

I am using JWT auth. The JWT has a TTL of 5 mins, so I need to update the JWT token at regular intervals. At the moment I am setting this in the header part of dotnetify.react.connect. I am fetching a new JWT from the auth provder at regular intervals before it will expire, but how do I update the header to use for authorization from react?

this.vm = dotnetify.react.connect("vm", this, {
headers: Auth.getAuthHeader(),
});

@dsuryd
Copy link
Owner

dsuryd commented Jun 8, 2020

Try this: vm.dispatch({$headers: "<new token>"})

@Sigve84
Copy link
Author

Sigve84 commented Jun 15, 2020

Tried it, and it do not seem to work. principal = ValidateBearerToken(ParseHeaders(hubContext.Headers), out validatedToken); still validates the old JWT token

@dsuryd dsuryd added the bug label Jun 15, 2020
dsuryd pushed a commit that referenced this issue Jun 15, 2020
…t dispatch (#251).  Add refresh token example and unit test.
@dsuryd
Copy link
Owner

dsuryd commented Jun 15, 2020

There was a bug in the extract headers middleware which is now fixed in the repo. This will be how a client can update the token in the headers:

this.vm.$dispatch({ $headers: { Authorization: 'Bearer ' + jwt.access_token }})

@dsuryd dsuryd closed this as completed Jun 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants