@loopback/docs
Version:
Documentation files rendered at [https://loopback.io](https://loopback.io)
37 lines (23 loc) • 1.1 kB
Markdown
lang: en
title: 'API docs: authentication.tokenservice.generatetoken'
keywords: LoopBack 4.0, LoopBack 4, Node.js, TypeScript, OpenAPI
sidebar: lb4_sidebar
editurl: https://github.com/loopbackio/loopback-next/tree/master/packages/authentication
permalink: /doc/en/lb4/apidocs.authentication.tokenservice.generatetoken.html
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [@loopback/authentication](./authentication.md) > [TokenService](./authentication.tokenservice.md) > [generateToken](./authentication.tokenservice.generatetoken.md)
## TokenService.generateToken() method
Generates a token string based on a user profile
<b>Signature:</b>
```typescript
generateToken(userProfile: UserProfile): Promise<string>;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| userProfile | [UserProfile](./security.userprofile.md) | A UserProfile for which a token should be generated. |
<b>Returns:</b>
Promise<string>
a generated token/secret for a given UserProfile.