IBM / ibm-cloud-functions-refarch-web-application

Create a serverless, event-driven application with Apache OpenWhisk on IBM Cloud Functions that executes code in response to the loading of web pages.
Apache License 2.0
3 stars 7 forks source link

Redirect after login with AppId fails.... #13

Open jthomas opened 5 years ago

jthomas commented 5 years ago

I've run through all the steps successfully until local web app section (https://github.com/IBM/ibm-cloud-functions-refarch-web-application#setup-of-local-web-application).

Running ng serve and opening http://localhost:4200 I can see the login button.

Clicking the button redirects me to...

https://eu-gb.appid.cloud.ibm.com/oauth/v4/8a86ad51-2e52-49cf-b743-fede9dcf6a5f/authorization?response_type=code&client_id=6c2d8b1d-af68-4f75-9430-dbd3146c90ea&redirect_uri=https://service.eu.apiconnect.ibmcloud.com/gws/apigateway/api/9a1a94007233b92cb29da1d865b76477d7ba0c46629feb061ed4bc4454091059/login/login

...which is the login screen for App Id. Using the username and password provided from the demo script (user@demo.email, verysecret) - I get redirected to (https://service.eu.apiconnect.ibmcloud.com/gws/apigateway/api/9a1a94007233b92cb29da1d865b76477d7ba0c46629feb061ed4bc4454091059/login/login?code=AwkJQjdhwpdZwqIEwpsJOsOaFsKCwoVvwr8zPxE4w4LDrsKaKMKXw7EuwqHCmsOKwq3ChcOEwpzCqcKww78ZaGvCljPDqcO3WyTDocOHw57Dr8KNPsOdGnrCtVQMBFrCvsKHOsOVBcKZw67Dm8K6BMKdPUZ8woR7wqfClsKrf8KiLHXDrE7DhzbDgsO3wo0-ZlHDqsOsCVTDs8OYAMOFc8OMw4bDlwfDrh8Nw6FmwqnCiMObwpFuwq05w511ZFllwo0vJsKEWnvDiG5yRFZjbTkDJsOWwozCm8KBw6XDucKrw5B3ZMKxJRLDiMOUOsKcwqXDmMO2w6cOwpnDgcOYwrfCq1YxDGDDlkdVTMOOw6ImFsOSCMKBwoI3w4ZNw54Fw4ow) which does not exist.

Shouldn't this be re-directing me to the localhost:4200 in the demo mode?

loafyloaf commented 5 years ago

@jthomas I am unable to replicate this issue. after logging in, I am redirected to http://localhost:4200/home?access_token=blahblahblah&refresh_token=undefined&expires_in=3600&user_name=user@demo.email

jthomas commented 5 years ago

I've tried this again with the same results. Can @mrutkows or @nimicent try to follow these instructions and see if they hit the same issue as me?

I've tried debugging this and think the Swagger used to create the Login APIs is incorrect. AppID is supposed to redirect to a Web Action which then redirects to localhost. Whatever the setup script is doing, the swagger has the web actions config incorrectly configured. Looking at the sample Swagger used in function-login/swagger-login.json it expects the application to run in the us-south, which is incorrect. The changes to the swagger do not take account of the region for one...

jthomas commented 5 years ago

@loafyloaf Can you try setting this up in a new namespace on a non-US region (to replicate having a fresh account like an external developer) and see if this work?

mrutkows commented 5 years ago

@jthomas everything works well up until I attempt "ng serve" and apparently I do not have the angular CLI installed... is this a missing pre-req.?

Manually installed Angular CLI from: https://cli.angular.io/ i.e., $ npm install -g @angular/cli

mrutkows commented 5 years ago

After installing Angular CLI and running ng serve , the application came up and since I was instructed to Open http://localhost:4200 in your browser. I opted to "login using Google" (for grins) and it indicated it had logged me in, but then protected API failed:

Screen Shot 2019-06-04 at 8 01 45 AM

and the FB (same):

Screen Shot 2019-06-04 at 8 03 32 AM

am I supposed to be logging in this early as it appears there are more scripts to run at this stage BUT since I started (did not launch a separate process) the "server". I need another command line pointed in the same root dir of the cloned project ;)

mrutkows commented 5 years ago

If I indeed open another terminal and invoke the COS script (i.e., $ scripts/setup-object-storage.sh) I get this message:

You can now open index.html but the app does not work yet: https://s3.us-south.objectstorage.softlayer.net/serverlessweb-e64d1c50-0794-4db5-8399-8eeedd47495d/index.html and the pattern instructions say To try the web application, open the URL that you get in the terminal. BUT I get this:

Screen Shot 2019-06-04 at 8 40 05 AM
mrutkows commented 5 years ago

attempting to continue (not sure if I should really be accessing any of the URLs the scripts say I should "open") as I still see more instructions... So I ran the last script $ scripts/setup-html-function.sh...

and the resultant URL from this scripts: https://service.us.apiconnect.ibmcloud.com/gws/apigateway/api/2e8784598e7c0d73062088fd120a7f8b2af6e73f1bc40ff224106716a2c27cd0/serverless/web resulted in a blank web page.

nimicent commented 5 years ago

@mrutkows @jthomas Okay so everyone, do we think we need to file a github issue for this on IBM Cloud?

jthomas commented 5 years ago

As neither Matt nor I can get it working following the instructions - there seems to be an issue in the instructions or the repo. I've asked if @loafyloaf can try following the instructions in a different region and clean namespace to replicate the issues. We should start with that.

nheidloff commented 5 years ago

@jthomas is right. The sample only works for us-south. To fix this, the following code needs to be extended: https://github.com/IBM/ibm-cloud-functions-refarch-web-application/blob/master/scripts/setup-login-function.sh#L103

nimicent commented 5 years ago

@nheidloff Thank you. @loafyloaf what do you think about this task?

loafyloaf commented 5 years ago

since app id is only available in 5 regions (dallas, tokyo, frankfurt, london, syndey), I guess options for setup should be limited to those 5?

mrutkows commented 5 years ago

@loafyloaf it would be wise to state up front the App ID region requirement with known supported regions "at the time of authoring"... (but hey, in the future ...) so ...

In addition, is there a command line test we can put in some aside (commentary block) that provides a command to test if App ID is avail. in a given region ("run this test to make sure your region has App ID avail." type of thing)?