Skip to content

Commit 40e7cb4

Browse files
committed
doc(sdk) update documentation for exchangeCode function
1 parent 4729f80 commit 40e7cb4

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

docs/README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,20 +158,26 @@ This API has exactly the same parameters as `onboard`, the only difference being
158158

159159
### exchangeToken
160160

161-
Since we are using PKCE/Code grant, we will have to exchange the `code` for a token. You can optionally pass `code` via options parameter or it will fallback to automatically extract it from the browser URL.
161+
Use this function to exchange an authorization `code` for a token. You can optionally pass `code` via options parameter, otherwise it will automatically extract the `code` URL parameter of the current URL.
162162

163-
`code` will be invalidated (can be used only once) after exchanged for a token, it is your responsibility to store the token yourself as the SDK does not store it internally.
163+
The `code` can be used only once. The SDK does not store it internally, you have to store it in your application.
164164

165165
Refer [here](https://www.oauth.com/oauth2-servers/pkce/authorization-code-exchange/) for more details.
166166

167167
<h6>Usage:</h6>
168168

169-
One way to use this API is by calling it in the script on your redirection page. For example, if `authorize` redirects to `https://yourapp.com/callback?code=somecode`, you can call this function in the script loaded on that redirection page and the client library will automatically extract the code to exchange for a token.
169+
One way to use this API is by calling it on your redirection page. For example, if `authorize` redirects to `https://yourapp.com/callback?code=somecode`, you can call this function in the script loaded on that redirection page and the client library will automatically extract the code to exchange for a token.
170170

171171
Alternatively, you can extract the `code` manually from the redirect URL and pass it to this function via the options object yourself.
172172

173173
```javascript
174174
const token = await mtLinkSdk.exchangeToken(options);
175+
token.access_token; // access token
176+
token.refresh_token; // refresh token
177+
token.token_type; // token type
178+
token.created_at: // created at in seconds
179+
token.expires_in; // expiry in seconds
180+
token.scope; // scope of the token
175181
```
176182

177183
| Parameter | Type | Required | Default Value | Description |
@@ -253,7 +259,7 @@ This method generates a URL to log out the guest. See the `logout` API for detai
253259
mtLinkSdk.logoutUrl(options);
254260
```
255261

256-
This API has exactly the same parameters as `logout`, the only difference being that it returns an URL instead of opening immediately with `window.open`.
262+
This API has exactly the same parameters as `logout`, the only difference being that it returns an URL instead of opening immediately with `window.open`.
257263

258264
#### Open Vault Services Page
259265

@@ -355,7 +361,7 @@ This method can generate URLs for various services provided by Moneytree, such a
355361
mtLinkSdk.openServiceUrl(serviceId, options);
356362
```
357363

358-
This API has exactly the same parameters as `openService`, the only difference being that it returns an URL instead of opening immediately with `window.open`.
364+
This API has exactly the same parameters as `openService`, the only difference being that it returns an URL instead of opening immediately with `window.open`.
359365

360366
### requestLoginLink
361367

0 commit comments

Comments
 (0)