Added shell script to generate authcode
authorAndriy Gudz <a.gudz@samsung.com>
Fri, 21 Apr 2017 11:18:21 +0000 (14:18 +0300)
committerAndriy Gudz <a.gudz@samsung.com>
Fri, 21 Apr 2017 11:18:21 +0000 (14:18 +0300)
demo/iot-es/github-code.sh [new file with mode: 0755]

diff --git a/demo/iot-es/github-code.sh b/demo/iot-es/github-code.sh
new file mode 100755 (executable)
index 0000000..785112c
--- /dev/null
@@ -0,0 +1,41 @@
+EMAIL='webappsjohn'
+PASS='rewg4321'
+
+COOKIES='cookies.txt'
+# USER_AGENT='Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/57.0.2987.98 Chrome/57.0.2987.98 Safari/537.36'
+            
+LOGIN_PAGE=$(curl -s -X GET 'https://github.com/login'  -b $COOKIES -c $COOKIES )
+
+#echo ${#LOGIN_PAGE}
+
+if [ ${#LOGIN_PAGE} -ge 100 ]; then
+
+       LOGIN_PAGE_TOKEN=$(echo ${LOGIN_PAGE} | grep -Po 'authenticity_token.*value="\K.*==')
+       #echo $LOGIN_PAGE
+       echo $LOGIN_PAGE_TOKEN
+
+       curl -s -X POST 'https://github.com/session' \
+       --data "commit=Sign+in" \
+       --data-urlencode "utf8=✓" \
+       --data-urlencode "authenticity_token=${LOGIN_PAGE_TOKEN}" \
+       --data-urlencode "login=${EMAIL}" \
+       --data-urlencode "password=${PASS}" \
+       -b $COOKIES -c $COOKIES > /dev/null
+       #--trace-ascii /dev/stdout #--verbose #-i --trace-ascii /dev/stdout
+fi
+
+CODE_RESPONCE=$(curl -s -X GET 'https://github.com/login/oauth/authorize?client_id=ea9c18f540323b0213d0' -b $COOKIES -c $COOKIES)
+CODE_TOKEN=$(echo ${CODE_RESPONCE} | grep -Po 'code=\K[a-z0-9]*')
+
+#echo $CODE_RESPONCE
+echo $CODE_TOKEN
+
+
+# -H "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8" \
+# -H "Accept-Encoding: gzip, deflate, br" \
+# -H "Accept-Language: en-US,en;q=0.8,ru;q=0.6,uk;q=0.4" \
+# -H "Origin: https://github.com" \
+# -H "Referer: https://github.com/" \
+# -H "Connection: keep-alive" \
+# -H "Cache-Control: max-age=0" \
+# -H "Upgrade-Insecure-Requests: 1" \
\ No newline at end of file