esbenp / esbenp/redux-refresh-token
How to pass a custom body on token refresh request
- Dominant language
- JavaScript
- Stars
- 37
- Forks
- 7
- PR merge metrics
- No merged PRs in 30d
Description
Hello!
I have a question about usage this module.
My authentication API is using OAuth 2.0 protocol and to refresh a token I need pass some key/value params on the body.
Example:
```
{
"client_id": CLIENT_ID,
"client_secret": CLIENT_SECRET,
"grant_type": "refresh_token",
"refresh_token": "A_VERY_BIG_STRING"
}
```
Code example:
```
export const attemptTokenRefresh = () => {
return async (dispatch, getState) => {
const state = getState();
dispatch({
[CALL_API]: {
endpoint: '/auth/oauth2_token',
method: 'POST',
body: {
client_id: CLIENT_ID,
client_secret: CLIENT_SECRET,
grant_type: 'refresh_token',
refresh_token: state.auth.refresh_token
},
types: [
ActionTypes.TOKEN_REFRESH_REQUEST,
ActionTypes.TOKEN_REFRESH_SUCCESS,
ActionTypes.TOKEN_REFRESH_FAILURE
]
}
});
};
};
```
I'm passing this parameters at the *attemptTokenRefresh* action, but I don't know if it's the best way to do that. What you think?
Contributor guide
No contributing guide indexed for this repository
Research direction
The entry point named is the attemptTokenRefresh action, which dispatches CALL_API with a POST body. First determine from the module’s middleware/API contract whether caller-supplied refresh parameters are supported; done means the supported usage is clear and verified for the OAuth 2.0 example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api, authentication
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100