Last active
March 19, 2019 08:40
-
-
Save buckett/ed3217fced4b9d129758157b4476aaa6 to your computer and use it in GitHub Desktop.
Revisions
-
buckett revised this gist
Mar 19, 2019 . 1 changed file with 3 additions and 3 deletions.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 charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ # Just pulls OAuth token for Canvas from keychain and puts it in the Authorization header # You can set passwords with: # security add-generic-password -a buckett -s canvas.instructure.com -w .... # and if you need to update a token you need to first delete it with: # security delete-generic-password -a buckett -s canvas.instructure.com # This will also mean that the the security tool has read access by default. @@ -13,10 +13,10 @@ canvas_hosts=(${CCURL_HOSTS}) # If your canvas account isn't your unix username set it with: # export CCURL_USER=myusername account=${CCURL_USER:-${USER}} if [ -z "$canvas_hosts" ]; then echo "You need to set the CCURL_HOSTS environmental variable to the hosts your want to add authorisation for." exit 2 fi -
buckett revised this gist
Mar 19, 2019 . 1 changed file with 1 addition and 1 deletion.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 charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ # Just pulls OAuth token for Canvas from keychain and puts it in the Authorization header # You can set passwords with: # security add-generic-password -a buckett -s canvas.instructure.com -w token_value_here # and if you need to update a token you need to first delete it with: # security delete-generic-password -a buckett -s canvas.instructure.com # This will also mean that the the security tool has read access by default. -
buckett created this gist
Mar 19, 2019 .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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,41 @@ #!/bin/bash # Canvas cURL # Just pulls OAuth token for Canvas from keychain and puts it in the Authorization header # You can set passwords with: # security add-generic-password -a buckett -s canvas.instructure.com -w .... # and if you need to update a token you need to first delete it with: # security delete-generic-password -a buckett -s canvas.instructure.com # This will also mean that the the security tool has read access by default. # This should be set with something like: # export CCURL_HOSTS="inst.instructure.com inst.test.instructure.com inst.beta.instructure.com" canvas_hosts=(${CCURL_HOSTS}) # If your canvas account isn't your unix username set it with: # export CCURL_USER=myusername account= ${CCURL_USER:-${USER}} if [ -z "$canvas_hosts" ]; then echo "You need to set the CCURL_HOSTS environmental variable to the hosts your want to add authorisation for."" exit 2 fi for host in ${canvas_hosts[@]}; do if [[ $@ == *${host}* ]]; then service=$host break fi done if [ -z "$service" ]; then echo "Failed to find service in arguments." 1>&2 exit 2 fi token=$(security find-generic-password -s ${service} -a ${account} -w 2>/dev/null) if [ -z "$token" ]; then echo "Failed to find token, looking for account $account for $service" 1>&2 exit 3 fi exec curl -H "Authorization: Bearer ${token}" "$@"