cordova-spotify-oauth
Advanced tools
Comparing version 0.1.10 to 0.1.11
@@ -17,2 +17,15 @@ 'use strict'; | ||
// add CORS headers to response | ||
// Reference: https://serverless.com/blog/cors-api-gateway-survival-guide/#cors-response-headers | ||
function cors(response) { | ||
if (response) { | ||
const headers = response.headers || {}; | ||
headers["Access-Control-Allow-Origin"] = "*"; // Required for CORS support to work | ||
headers["Access-Control-Allow-Credentials"] = true; // Required for cookies, authorization headers with HTTPS | ||
response.headers = headers; | ||
} | ||
return response; | ||
} | ||
const spotifyRequest = params => { | ||
@@ -51,3 +64,3 @@ return new Promise((resolve, reject) => { | ||
if (!params.code) { | ||
callback(null, { | ||
callback(null, cors({ | ||
statusCode: 400, | ||
@@ -57,3 +70,3 @@ body: JSON.stringify({ | ||
}) | ||
}); | ||
})); | ||
return; | ||
@@ -81,3 +94,3 @@ } | ||
.then(response => { | ||
callback(null, response); | ||
callback(null, cors(response)); | ||
}); | ||
@@ -90,3 +103,3 @@ }; | ||
if (!params.refresh_token) { | ||
callback(null, { | ||
callback(null, cors({ | ||
statusCode: 400, | ||
@@ -96,3 +109,3 @@ body: JSON.stringify({ | ||
}) | ||
}); | ||
})); | ||
return; | ||
@@ -118,4 +131,4 @@ } | ||
.then(response => { | ||
callback(null, response); | ||
callback(null, cors(response)); | ||
}); | ||
}; |
{ | ||
"name": "cordova-spotify-oauth", | ||
"version": "0.1.10", | ||
"version": "0.1.11", | ||
"description": "Cordova plugin for authenticating with Spotify", | ||
@@ -5,0 +5,0 @@ "main": "www/build/spotify-oauth.min.js", |
@@ -66,3 +66,3 @@ # Cordova Spotify OAuth Plugin | ||
The authorization code flow requires server code for security. These come in the form of two HTTP endpoints, one for the auth code exchange, and the other one for access token refresh. The SDK will POST `application/x-www-form-urlencoded` data and expects JSON back. | ||
The authorization code flow requires server code for security. These come in the form of two HTTP endpoints, one for the auth code exchange, and the other one for access token refresh. The SDK will POST `application/x-www-form-urlencoded` data and expects JSON back. Ensure you have proper CORS config set up. | ||
@@ -69,0 +69,0 @@ To easily implement them, we built a [Serverless][serverless] service for [AWS Lambda][aws-lambda] over in the [`oauth-token-api`][token-api-example] folder. Make sure you [install the Serverless Framework properly][serverless-installation]! |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
318202
602