Skip to content

Commit 6cbdfc8

Browse files
committed
Allow user to control credentials of request
1 parent 55b9e52 commit 6cbdfc8

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
| dialogWidth |number |600 |dialog width |
3939
| dialogHeight |number |400 |dialog height |
4040
| showIcon |bool |true |should default icon be visible |
41+
| credentials |string |same-origin |indicates whether the user agent should send cookies from the other domain in the case of cross-origin requests. Possible values: `omit`, `same-origin`, `include`|
4142

4243
# Examples
4344

src/index.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class TwitterLogin extends Component {
2222

2323
return window.fetch(this.props.requestTokenUrl, {
2424
method: 'POST',
25-
credentials: 'same-origin',
25+
credentials: this.props.credentials,
2626
headers: {
2727
'Content-Type': 'application/json'
2828
}
@@ -90,7 +90,7 @@ class TwitterLogin extends Component {
9090
getOathToken(oAuthVerifier, oauthToken) {
9191
return window.fetch(`${this.props.loginUrl}?oauth_verifier=${oAuthVerifier}&oauth_token=${oauthToken}`, {
9292
method: 'POST',
93-
credentials: 'same-origin',
93+
credentials: this.props.credentials,
9494
headers: {
9595
'Content-Type': 'application/json'
9696
}
@@ -136,7 +136,8 @@ TwitterLogin.propTypes = {
136136
className: PropTypes.string,
137137
dialogWidth: PropTypes.number,
138138
dialogHeight: PropTypes.number,
139-
showIcon: PropTypes.bool
139+
showIcon: PropTypes.bool,
140+
credentials: PropTypes.oneOf(['omit', 'same-origin', 'include']),
140141
};
141142

142143
TwitterLogin.defaultProps = {
@@ -145,7 +146,8 @@ TwitterLogin.defaultProps = {
145146
disabled: false,
146147
dialogWidth: 600,
147148
dialogHeight: 400,
148-
showIcon: true
149+
showIcon: true,
150+
credentials: 'same-origin'
149151
};
150152

151153
export default TwitterLogin;

0 commit comments

Comments
 (0)