title: Use UserManager GenerateUserTokenAsync to create custom tokens with extra data
body: <p>I am using ASP.NET Core 2.2 and I need to generate custom tokens in my application.</p>
  
  <p>Asp.Net Core Identity UserManager can generate classic tokens like EmailVerification, ...</p>
  
  <p>But it has also a method to generate tokens with different purposes (<a href="https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.identity.usermanager-1.generateusertokenasync?view=aspnetcore-2.2" rel="nofollow noreferrer">MSFT Docs</a>):</p>
  
  <pre><code>public virtual System.Threading.Tasks.Task&lt;string&gt; GenerateUserTokenAsync (TUser user, string tokenProvider, string purpose);
  </code></pre>
  
  <p>I need to generate a token with the following information:</p>
  
  <ol>
  <li>Purpose = AddUserToProject</li>
  <li>User = A given user</li>
  <li>ProjectId = The Project Id to which the User should be added.</li>
  <li>RoleId = The Role Id of the User in the Project</li>
  </ol>
  
  <p>On GenerateUserTokenAsync I can add the User and the Purpose ...</p>
  
  <p>But I'm not sure how to add (3) and (4) e.g. ProjectId and RoleId.</p>
  
  <p>And how can I retrieve it later so I can actually perform the action.</p>
  
  <p>How should I do this?</p>