question

6666666 avatar image
0 Votes"
6666666 asked YijingSun-MSFT commented

How to use token which is create in web api in signalr ?

If it is login in web api how to use it directly in signalr?

dotnet-aspnet-signalr
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

YijingSun-MSFT avatar image
0 Votes"
YijingSun-MSFT answered YijingSun-MSFT commented

Hi @6666666 ,

You need firstly send the request to the account controller to auth. Then if the login success, it will return an access token to the client.

Then the client will use this access token to access the api resources.

The identity has its own logic to check the access token.



If the answer is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our  documentation  to enable e-mail notifications if you want to receive the related email notification for this thread.

Best regards,
Yijing Sun

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Yes I do as you say.

  1. send request to the account controller to auth.

  2. get the token

  3. use token to access the api

  4. get 401

the token is Bearer token nomatter in postman and swagger debug it will be 401



0 Votes 0 ·

Hi @6666666 ,As far as I think, 401 error is the wrong of authentication. First,you could check if your token is effective and then you should check if the middleware of authentication is set before api.

1 Vote 1 ·