-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
1,573 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# Created by .ignore support plugin (hsz.mobi) | ||
### JetBrains template | ||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm | ||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 | ||
|
||
# User-specific stuff: | ||
.idea/ | ||
|
||
## File-based project format: | ||
*.iws | ||
|
||
## Plugin-specific files: | ||
|
||
# IntelliJ | ||
/out/ | ||
|
||
# mpeltonen/sbt-idea plugin | ||
.idea_modules/ | ||
|
||
# JIRA plugin | ||
atlassian-ide-plugin.xml | ||
|
||
# Crashlytics plugin (for Android Studio and IntelliJ) | ||
com_crashlytics_export_strings.xml | ||
crashlytics.properties | ||
crashlytics-build.properties | ||
fabric.properties | ||
### Node template | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules | ||
jspm_packages | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# SpotifySDK | ||
src/ios/spotify-sdk/ | ||
src/android/spotify-auth/ | ||
src/android/spotify-sdk/ | ||
|
||
# Serverless | ||
.serverless/ | ||
|
||
# env config | ||
.env | ||
|
||
# Android | ||
.gradle/ | ||
|
||
# Webpack | ||
www/build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2017 Festify | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Cordova Spotify SDK Plugin (Beta) | ||
|
||
An [Apache Cordova](https://cordova.apache.org/) plugin providing a thin wrapper over the Spotify SDK for iOS and Android. | ||
|
||
## Features | ||
|
||
This plugin provides a very thin layer over the authentication and playback functionality of the Spotify SDK. It allows your users to authenticate using OAuth 2.0 and allows you to play Spotify tracks via their URI. Metadata functionality has deliberately been left out in favor of the [Web API](https://developer.spotify.com/web-api/). After your users have been authenticated, you are given the access token, so accessing the Web API is trivial. | ||
|
||
## Stability | ||
|
||
This plugin is currently in beta. This means its reasonably stable but hasn't seen much production use yet. This plugin will be used in the new [Festify](https://github.com/Festify/app), so it will be production-ready once Festify is released. We will fix bugs as soon as we find them. | ||
|
||
## Contributing | ||
|
||
Pull requests are very welcome! Please use the [gitmoji](https://gitmoji.carloscuesta.me/) style for commit messages. | ||
|
||
## Installation | ||
|
||
```bash | ||
git clone https://github.com/Festify/cordova-spotify | ||
cd ./MyCordovaProject | ||
cordova plugin add ../cordova-spotify | ||
``` | ||
|
||
An npm-based installation as well as API documentation will be provided at a later stage when the stability has improved. | ||
|
||
Note: Make sure your installation path doesn't contain any spaces. | ||
|
||
## OAuth Code Grant Flow | ||
|
||
The Spotify SDK needs some server code because you don't want to login your users repeatedly every hour: [Documentation](https://developer.spotify.com/technologies/spotify-ios-sdk/token-swap-refresh/) | ||
|
||
To implement the endpoints for `tokenSwapURL` and `tokenRefreshURL` we built a [Serverless](https://serverless.com) service that you can deploy to AWS Lambda. Make sure you [install the Serverless Framework properly](https://serverless.com/framework/docs/providers/aws/guide/installation/)! | ||
|
||
For the execution of the functions to work you need to set some environmental configuration in the file `oauth-token-api/.env` | ||
|
||
```bash | ||
CLIENT_ID="<Your Spotify Client ID>" | ||
CLIENT_SECRET="<Your Spotify Client Secret>" | ||
CLIENT_CALLBACK_URL="<The callback url of your app>" # e.g. "festify-spotify://callback" | ||
ENCRYPTION_SECRET="<Secret used to encrypt the refresh token - please generate>" | ||
``` | ||
|
||
You can then deploy the functions to AWS: | ||
|
||
```bash | ||
cd oauth-token-api | ||
serverless deploy | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
android { | ||
defaultConfig { | ||
minSdkVersion 15 | ||
targetSdkVersion 22 | ||
} | ||
|
||
packagingOptions { | ||
exclude 'META-INF/NOTICE' | ||
exclude 'META-INF/LICENSE' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env bash | ||
|
||
AUTH_INSTALL_PATH="plugins/rocks.festify.cordova-spotify/src/android/spotify-auth" | ||
AUTH_DOWNLOAD_PATH="https://github.com/spotify/android-auth/archive/1.0.tar.gz" | ||
SDK_INSTALL_PATH="plugins/rocks.festify.cordova-spotify/src/android/spotify-sdk" | ||
SDK_DOWNLOAD_PATH="https://github.com/spotify/android-sdk/archive/24-noconnect-2.20b.tar.gz" | ||
|
||
if [ ! -d "$AUTH_INSTALL_PATH" ]; then | ||
mkdir -p "$AUTH_INSTALL_PATH" | ||
curl -LsS $AUTH_DOWNLOAD_PATH | tar -xz -C "$AUTH_INSTALL_PATH" --strip 1 | ||
else | ||
echo "Skipping auth library download since it's already there." | ||
fi | ||
|
||
if [ ! -d "$SDK_INSTALL_PATH" ]; then | ||
mkdir -p "$SDK_INSTALL_PATH" | ||
curl -LsS $SDK_DOWNLOAD_PATH | tar -xz -C "$SDK_INSTALL_PATH" --strip 1 | ||
else | ||
echo "Skipping streaming SDK download since it's alredy there." | ||
fi | ||
|
||
cd $(dirname $0)/src/android/spotify-auth | ||
echo "include ':auth-lib'" > settings.gradle | ||
|
||
if [ ! -f "auth-lib/build/outputs/aar/spotify-android-auth-1.0.0.aar" ]; then | ||
./gradlew clean build | ||
else | ||
echo "Skipping auth library build since the AAR is already there." | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env bash | ||
|
||
INSTALL_PATH="plugins/rocks.festify.cordova-spotify/src/ios/spotify-sdk" | ||
DOWNLOAD_PATH="https://github.com/spotify/ios-sdk/archive/beta-25.tar.gz" | ||
|
||
if [ ! -d $INSTALL_PATH ]; then | ||
mkdir -p $INSTALL_PATH | ||
curl -LsS $DOWNLOAD_PATH | tar -xzv -C $INSTALL_PATH --strip 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# package directories | ||
node_modules | ||
jspm_packages | ||
|
||
# Serverless directories | ||
.serverless |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
'use strict'; | ||
|
||
const crypto = require('crypto'); | ||
|
||
const algo = 'aes-256-cbc'; | ||
|
||
module.exports.encrypt = (text, key) => { | ||
const cipher = crypto.createCipher(algo, key); | ||
return cipher.update(text, 'utf8', 'hex') + cipher.final('hex'); | ||
}; | ||
|
||
module.exports.decrypt = (text, key) => { | ||
const decipher = crypto.createDecipher(algo, key); | ||
return decipher.update(text, 'hex', 'utf8') + decipher.final('utf8'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"name": "spotify-oauth-token-api", | ||
"version": "1.0.0", | ||
"description": "The AWS lambda service that is responsible for dealing with OAuth token refresh and exchange.", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/Festify/cordova-spotify.git" | ||
}, | ||
"keywords": [ | ||
"cordova", | ||
"spotify", | ||
"token", | ||
"exchange", | ||
"oauth" | ||
], | ||
"author": "Festify Dev Team <[email protected]>", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/Festify/cordova-spotify/issues" | ||
}, | ||
"homepage": "https://github.com/Festify/cordova-spotify#readme", | ||
"dependencies": { | ||
"dotenv": "^2.0.0", | ||
"es6-promise": "^4.0.5", | ||
"qs": "^6.3.0", | ||
"request": "^2.79.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
|
||
service: oauth-token-api | ||
|
||
provider: | ||
name: aws | ||
runtime: nodejs4.3 | ||
region: eu-central-1 | ||
profile: festify | ||
memorySize: 128 | ||
|
||
package: | ||
include: | ||
- lib/** | ||
|
||
functions: | ||
exchangeCode: | ||
handler: spotifyTokenService.exchangeCode | ||
events: | ||
- http: | ||
path: exchange | ||
method: post | ||
refreshToken: | ||
handler: spotifyTokenService.refreshToken | ||
events: | ||
- http: | ||
path: refresh | ||
method: post |
Oops, something went wrong.