Creating Tokens · tymondesignsjwt | laravel jwt encode
Thereareseveralwaystocreateatokenwithinthepackage.Therearesimplewaystodoit,andmoreadvancedmethodsifyouwantgreatercontrol.Outoftheboxthereareanumberofrequiredclaims,Althoughthiscanbeconfigured:subSubject-Thisholdstheidentifierforthetoken(defaultstouserid)iatIssuedAt-Whenthetokenwasissued(unixtimestamp)expExpiry-Thetokenexpirydate(unixtimestamp)nbfNotBefore-Theearliestpointintimethatthetokencanbeused(unixtimestamp)issIssuer-Theissuerofthetoken(defaultstotherequesturl)jtiJWTId-Auniqueidentifier...
There are several ways to create a token within the package. There are simple ways to do it, and more advanced methods if you want greater control.
Out of the box there are a number of required claims, Although this can be configured:
sub Subject - This holds the identifier for the token (defaults to user id)
iat Issued At - When the token was issued (unix timestamp)
exp Expiry - The token expiry date (unix timestamp)
nbf Not Before - The earliest point in time that the token can be used (unix timestamp)
iss Issuer - The issuer of the token (defaults to the request url)
jti JWT Id - A unique identifier for the token (md5 of the sub and iat claims)
aud Audience - The intended audience for the token (not required by default)
Custom claims are also allowed. More on that later.
Creating a Token based on the users credentialsThe most common way to create a token would be to authenticate the user via th...