Home > Net >  Webapi string of data, someone help me out? ($)
Webapi string of data, someone help me out? ($)

Time:11-21

This matter is,

Use request authentication is behind client_credentials front-end is a small program


Each a small program after the user login will get a token, then request other API with the token

Now found that sometimes is another user request data API,


Such as:

When A login, send into the token, will record the following information


Public Overrides the Function GrantClientCredentials (context As OAuthGrantClientCredentialsContext) As a Task

Dim oAuthIdentity=New ClaimsIdentity (context. The Options. AuthenticationType)
OAuthIdentity. AddClaim (New Claim (" code ", the Me. Logininfo. Code))



Dim ticket=New AuthenticationTicket (oAuthIdentity, New AuthenticationProperties ())
The context. Validated (ticket)

Context. OwinContext. The Response Headers. The Add (" Access - Control - Allow - Origin, "{}" * ")

Return MyBase. GrantClientCredentials (context)
End the Function

When A request other API, then call Dim ClaimsPrincipal As ClaimsPrincipal=HttpContext. Current. The value of the User to obtain code but sometimes get A is the value of another User,



CodePudding user response:

Debugging two user access token, is different?

CodePudding user response:

reference 1st floor is nu month god reply:
debug two user access token, is different?



Only occasionally, so I want to ask, I write if you have any questions,

CodePudding user response:

refer to the second floor lang_csdn response:
Quote: refer to 1st floor is nu month god reply:

Debugging two user access token, is different?



Only occasionally, so I want to ask, do you have any questions I spelled,

Then there must be some questions, sometimes it just means you concurrency is not big, but must be caused by using the Shared resource,
You put the Return MyBase. GrantClientCredentials (context) out and have a look, how to write,
Have a look at the whole class

CodePudding user response:

Whether with global/static variables method, and haven't lock

CodePudding user response:

reference 4 floor dmankill response:
is used the global/static variable method, and haven't lock



Public Class Helper

Shared Function GetLoginInfo () As LoginInfo

Dim l As New LoginInfo


If Not HttpContext. Current Is Nothing Then
Dim ClaimsPrincipal As ClaimsPrincipal=HttpContext. Current. The User
For Each c In ClaimsPrincipal. Claims
The Select Case c.T ype
Case "Role"
Their lives ole=c. alue
Case "ID", "
L.I D=CInt (c. alue)
Case "LoginName
"L.L oginName=c. alue
Case "NickName"
L.N ickName=c. alue
Case "clientno
"L.c lientno=c. alue

Case "code"
L.c ode=c. alue

Case "db"
L.d b=c. alue
Case "restfulurl
"Their lives estfulurl=c. alue
Case "ver"
L.v er=c. alue
End the Select
Next
The Else


End the If



Return the l
End the Function


This is a static method, is the cause,


The End of the Class
  • Related