Skip to content

Commit

Permalink
Add code-samples for token generation (#1174)
Browse files Browse the repository at this point in the history
* Add code-samples for token generation

* Add a newline in the code sample
  • Loading branch information
bidoubiwa committed Mar 10, 2022
1 parent 4fdfba2 commit 6297dc9
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -500,3 +500,19 @@ security_guide_delete_key_1: |-
authorization_header_1: |-
const client = new MeiliSearch({ host: 'http://localhost:7700', apiKey: 'masterKey' })
client.getKeys()
tenant_token_guide_generate_sdk_1: |-
const searchRules = {
'patient_medical_records': {
filter: 'user_id = 1'
}
}
const apiKey = 'B5KdX2MY2jV6EXfUs6scSfmC...'
const expiresAt = new Date('2025-12-20') // optional
const token = client.generateTenantToken(searchRules, {
apiKey: apiKey,
expiresAt: expiresAt,
})
tenant_token_guide_search_sdk_1: |-
const frontEndClient = new MeiliSearch({ host: 'http://127.0.0.1:7700', apiKey: token })
frontEndClient.index('patient_medical_records').search('blood test')

0 comments on commit 6297dc9

Please sign in to comment.