Skip to content

Commit 1d3bf11

Browse files
committed
docs: Add access token feature to user guide
1 parent c4adc3a commit 1d3bf11

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

js-miniapp-sdk/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,24 @@ miniApp.setScreenOrientation(ScreenOrientation.LOCK_LANDSCAPE) // or LOCK_PORTRA
203203
});
204204
```
205205
206+
### 7. Get access token
207+
208+
You can get an access token provided by the Host App. The Host App will be able to deny your request if your mini app ID is not approved to access the token.
209+
210+
This will return an object containing `token` and `validUntil` keys.
211+
212+
```javascript
213+
miniApp.getAccessToken()
214+
.then(data => {
215+
const isValid = data.validUntil.getTime() >= Date.now();
216+
if (isValid) {
217+
const token = data.token;
218+
// Use token
219+
}
220+
})
221+
.catch(error => console.error(error))
222+
```
223+
206224
## Advanced Usage
207225
208226
### Check Android/iOS device

0 commit comments

Comments
 (0)