This repository was archived by the owner on Jan 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Add example Sinatra application #3
Open
ZenCocoon
wants to merge
1
commit into
Asana:master
Choose a base branch
from
BookingSync:add-example-sinatra-application
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
|
@@ -15,3 +15,4 @@ spec/reports | |
test/tmp | ||
test/version_tmp | ||
tmp | ||
example/.powenv | ||
This file contains hidden or 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,2 @@ | ||
export ASANA_CLIENT_ID="" | ||
export ASANA_CLIENT_SECRET="" |
This file contains hidden or 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,5 @@ | ||
source "https://rubygems.org" | ||
|
||
gem "sinatra" | ||
gem "json" | ||
gem "omniauth-asana" |
This file contains hidden or 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,35 @@ | ||
# Asana OAuth Helper | ||
|
||
Small sinatra application to help you get your OAuth Token for your Asana Application. | ||
This is specially useful to play around Asana API. | ||
|
||
## Usage | ||
|
||
### Requirements: | ||
|
||
[POW](http://pow.cx/) - To run this Sinatra application. | ||
[Tunnelss](https://github.com/rchampourlier/tunnelss) - To use SSL | ||
|
||
_Note: Tricks for [persiting SSL with Tunnelss over reboot](http://www.sebgrosjean.com/en/news/2014/2/9/rails-with-ssl-in-development-with-pow-and-tunnels)_ | ||
|
||
### 1) Install dependencies | ||
|
||
```sh | ||
bundle install | ||
``` | ||
|
||
### 2) Setup your Asana Application credentials | ||
|
||
```sh | ||
cp .powenv.sample .powenv | ||
``` | ||
|
||
Edit the `ASANA_CLIENT_ID` and `ASANA_CLIENT_SECRET` environment variables from the `.powenv` file. | ||
|
||
### 3) Restart Pow | ||
|
||
Make sure to restart Pow, using: | ||
|
||
```sh | ||
touch tmp/restart.txt | ||
``` |
This file contains hidden or 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,50 @@ | ||
require "sinatra" | ||
require "json" | ||
require "omniauth-asana" | ||
|
||
use Rack::Session::Cookie | ||
|
||
use OmniAuth::Builder do | ||
provider :asana, ENV['ASANA_CLIENT_ID'], ENV['ASANA_CLIENT_SECRET'] | ||
end | ||
|
||
get "/" do | ||
<<-HTML | ||
<html> | ||
<head> | ||
<style> | ||
body { | ||
text-align: center; | ||
} | ||
|
||
a { | ||
display: inline-block; | ||
padding: 10px 20px; | ||
font-size: 16px; | ||
color: #fff; | ||
background-color: #1B57AA; | ||
text-decoration: none; | ||
border-radius: 4px; | ||
margin: 100px auto 0; | ||
} | ||
|
||
a:hover { | ||
background-color: #2b88dc; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<p><a href="/auth/asana">Sign in with Asana</a></p> | ||
</body> | ||
</html> | ||
HTML | ||
end | ||
|
||
get "/auth/:provider/callback" do | ||
request.env["omniauth.auth"].to_hash.to_json | ||
end | ||
|
||
get "/auth/failure" do | ||
content_type "text/plain" | ||
params[:message] | ||
end |
This file contains hidden or 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,7 @@ | ||
require 'rubygems' | ||
require 'bundler' | ||
Bundler.setup | ||
|
||
require './asana_oauth_helper' | ||
|
||
run Sinatra::Application |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't need to be here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As their's a
example/.powenv.sample
showing how to setup is environment variables with Pow I think not having this could quickly leak credentials to Git :/Why don't you like it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, in that case might make more sense to put in the .gitignore inside example :)