Name: Shiran Wang, GithubId: shiran8338 Javadoc: https://ucsb-cs56-w20.github.io/lab07_shiran8338/index.html Repo: https://github.com/ucsb-cs56-w20/lab07_shiran8338
-
You must first configure a Google OAuth app for http://localhost:8080 and obtain the client-id and client-secret.
Follow the instructions here: https://ucsb-cs56.github.io/topics/oauth_google_setup.
- For the application url, use http://localhost:8080
- For the callback url, also use http://localhost:8080/login/oauth2/code/google
- Note that on localhost, you typically need use
http
nothttps
-
You must then copy the file
localhost.json.SAMPLE
to the filelocalhost.json
.- Note that you SHOULD NOT edit
localhost.json.SAMPLE
directly. - The copied file
localhost.json
will NOT be commited to GitHub; it's in the.gitignore
- Note that you SHOULD NOT edit
-
Then, edit the
localhost.json
file and put in your client id and client secret in the places indicated. -
Finally, IN EACH terminal session where you are going to run
mvn spring-boot:run
, and EACH TIME after you change the values inlocalhost.json
, execute this command to load those values into the Unix environment:source env.sh
That means to source the contents of
env.sh
into the current shell. That loads the contents oflocalhost.json
into the environment variableSPRING_APPLICATION_JSON
, which causes those values to override those in theapplication.properties
file.On
bash
, you can also use. env.sh
(a dot followed by a space followed byenv.sh
) -
Now you are ready to do
mvn spring-boot:run
as usual, and see the application on http://localhost:8080.Try logging in with your GitHub account.
To run on Heroku, you must go BACK to GitHub and set up a DIFFERENT client id and client secret than the one you used for localhost.
-
Go to the heroku.com dashboard and create a new Heroku app with the name
cs56-f19-lab06-githubid
, replacinggithub
with your github id. -
Now you must configure a Google OAuth app for
https://cs56-w20-lab07-githubid.herokuapp.com
and obtain the client-id and client-secret.Follow the instructions here: https://ucsb-cs56.github.io/topics/oauth_google_setup.
- For the callback url, use https://cs56-w20-lab07-githubid.herokuapp.com/login/oauth2/code/google
- Note that on Heroku, you typically need use
https
nothttp
, and be sure to substitute YOUR githubid in place of githubid; also if you abbreviated your Heroku application name, use that in the callback url.
-
You must then copy the file
heroku.json.SAMPLE
to the fileheroku.json
.- Note that you SHOULD NOT edit
heroku.json.SAMPLE
directly. - The copied file
localhost.json
will NOT be commited to GitHub; it's in the.gitignore
- Note that you SHOULD NOT edit
-
Then, edit the
heroku.json
file and put in your client id and client secret in the places indicated. -
Now, you need either to be logged into CSIL where you can run the heroku command line tool, or you need the heroku command line (CLI) installed on your local system.
Use
heroku login
to login to the command line tool.The run the following script from the repo. You need to do this in the same directory where you entered the client id and client secret values into the
heroku.json
file.The name of the Heroku app should match yours (e.g. change
githubid
to your githubid)./setHerokuEnv.py --app cs56-w20-lab07-githubid
You should now be able to go to the Heroku Dashboard for your app online, e.g. this link (replacing
githubid
with yours)Click "Reveal Config Vars". You should see a configuration variable called
SPRING_APPLICATION_JSON
that contains the values that you entered for client id and client secret (i.e the contents ofheroku.json
). -
Now you are ready to do the steps you did in lab02 to connect your Heroku App to your Github repo, and deploy your app to Heroku and see it running.
Try logging in with your github account here.
Type this | to get this result |
---|---|
mvn package |
to make a jar file |
mvn spring-boot:run |
to run the web app |
./checkLocalhost.py |
to check the syntax of your localhost.json file |
./setHerokuEnv.py --app APPNAME |
to check the syntax of your heroku.json file and set the configuration variables for Heroku app APPNAME (requires logging in to Heroku CLI first) |