Skip to content

Commit

Permalink
Merge pull request #39 from Bynder/make_scopes_mandatory
Browse files Browse the repository at this point in the history
Made scope mandatory and removed deprecated login samples
  • Loading branch information
Daniel Sequeira authored Oct 24, 2019
2 parents 330f25c + c1c14e1 commit d27931f
Show file tree
Hide file tree
Showing 14 changed files with 8 additions and 979 deletions.
84 changes: 0 additions & 84 deletions samples/login.html

This file was deleted.

12 changes: 0 additions & 12 deletions samples/login.js

This file was deleted.

15 changes: 0 additions & 15 deletions samples/login_completed.html

This file was deleted.

8 changes: 3 additions & 5 deletions src/bynder-js-sdk.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const queryString = require("query-string");
const simpleOAuth2 = require("simple-oauth2");
const url = require("url");

const DEFAULT_SCOPES = "openid offline";
const defaultAssetsNumberPerPage = 50;

/**
Expand Down Expand Up @@ -196,10 +195,10 @@ class Bynder {
* Builds OAuth2 authorization URL.
* @return {String} Authorization URL
*/
makeAuthorizationURL(state) {
makeAuthorizationURL(state, scope) {
return this.oauth2.authorizationCode.authorizeURL({
redirect_uri: this.redirectUri,
scope: DEFAULT_SCOPES,
scope: scope,
state: state
});
}
Expand All @@ -212,8 +211,7 @@ class Bynder {
getToken(code) {
const tokenConfig = {
code: code,
redirect_uri: this.redirectUri,
scope: DEFAULT_SCOPES
redirect_uri: this.redirectUri
};

return this.oauth2.authorizationCode.getToken(tokenConfig).then(result => {
Expand Down
2 changes: 1 addition & 1 deletion tests/__snapshots__/login.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Make authorization URL should return correct authorization URL 1`] = `"https://integrations.getbynder.com/v6/authentication/oauth2/auth?response_type=code&client_id=5f5206f4-2d7a-4345-bd4c-12fad14ac111&redirect_uri=http%3A%2F%2Flocalhost%2Ftest%2Fcallback&scope=openid%20offline&state=state%20example"`;
exports[`Make authorization URL should return correct authorization URL 1`] = `"https://integrations.getbynder.com/v6/authentication/oauth2/auth?response_type=code&client_id=5f5206f4-2d7a-4345-bd4c-12fad14ac111&redirect_uri=http%3A%2F%2Flocalhost%2Ftest%2Fcallback&scope=offline&state=state%20example"`;
35 changes: 0 additions & 35 deletions tests/brands.test.js

This file was deleted.

91 changes: 0 additions & 91 deletions tests/collections.test.js

This file was deleted.

6 changes: 4 additions & 2 deletions tests/login.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ let bynder;

describe("Make authorization URL", () => {
bynder = new Bynder(configs);
const encodedRedirectUri = encodeURIComponent(configs.redirectUri);
const authorizationUrl = bynder.makeAuthorizationURL("state example");
const authorizationUrl = bynder.makeAuthorizationURL(
"state example",
"offline"
);

test("should return correct authorization URL", () => {
// Security token is random token so we compare without this
Expand Down
Loading

0 comments on commit d27931f

Please sign in to comment.