Skip to content

Commit

Permalink
Switch to using 'authorization' header instead of 'authentication' (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrove authored Jan 19, 2020
1 parent 9332832 commit 7cd1740
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/onegraph-auth/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
## OneGraph Auth

The main helper library for automating all-things authentication in the browser. Many services are supported for logging in/out of applications, and more details about the library can be found on [the OneGraph docs site](https://www.onegraph.com/docs/authentication.html).
The main helper library for automating all-things and/or authorization in the browser. Many services are supported for logging in/out of applications, and more details about the library can be found on [the OneGraph docs site](https://www.onegraph.com/docs/authentication.html).
17 changes: 10 additions & 7 deletions packages/onegraph-auth/src/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ function fetchQuery(
headers: {
'Content-Type': 'application/json',
Accept: 'application/json',
...(token ? {Authentication: `Bearer ${token.accessToken}`} : {}),
...(token ? {Authorization: `Bearer ${token.accessToken}`} : {}),
},
body: JSON.stringify({query, variables}),
}).then(response => response.json());
Expand All @@ -357,7 +357,7 @@ function exchangeCode(
const headers = {
'Content-Type': 'application/json',
Accept: 'application/json',
...(token ? {Authentication: `Bearer ${token.accessToken}`} : {}),
...(token ? {Authorization: `Bearer ${token.accessToken}`} : {}),
};
return fetch(URI.toString(url), {
method: 'POST',
Expand Down Expand Up @@ -586,9 +586,9 @@ class OneGraphAuth {
});
};

authHeaders = (): {Authentication?: string} => {
authHeaders = (): {Authorization?: string} => {
if (this._accessToken) {
return {Authentication: `Bearer ${this._accessToken.accessToken}`};
return {Authorization: `Bearer ${this._accessToken.accessToken}`};
} else {
return {};
}
Expand Down Expand Up @@ -806,9 +806,12 @@ class OneGraphAuth {
}
const foreignUserId =
typeof args === 'string' ? null : args.foreignUserId;
return fetchQuery(this._fetchUrl, loggedInQuery, {}, accessToken).then(
result => getIsLoggedIn(result, service, foreignUserId),
);
return fetchQuery(
this._fetchUrl,
loggedInQuery,
{},
accessToken,
).then(result => getIsLoggedIn(result, service, foreignUserId));
} else {
return Promise.resolve(false);
}
Expand Down

0 comments on commit 7cd1740

Please sign in to comment.