okta / samples-nodejs-express-4

Express 4 samples. Will publish an artifact that can be consumed by end-to-end sample repos
Other
120 stars 118 forks source link

Unable to find testenv file into current project in visual studio code #93

Open Rajshah1897 opened 3 years ago

Rajshah1897 commented 3 years ago

ISSUER=https://yourOktaDomain.com/oauth2/default SPA_CLIENT_ID=123xxxxx123

In which file we need to add the above field? not understand testenv

mraible commented 3 years ago

If you clone this repository, you should create a testenv file (that's it, no extension) in the root directory of the cloned repo.

Rajshah1897 commented 3 years ago

I changed it here.

is that ok? Please see that image as below. where is the root directory in this pic? Do I need to create testenv file inside the resource server?

image
mraible commented 3 years ago

The testenv file should be in the same directory as config.js.

Rajshah1897 commented 3 years ago

Ok Do I need to update anything in config.js?

mraible commented 3 years ago

No. It should read your values and override what's configured in there.

Rajshah1897 commented 3 years ago

Ok Do I need to setup testenv should be testenv.js? like that?

mraible commented 3 years ago

No, it should just be named testenv. It should not have a .js extension.

Rajshah1897 commented 3 years ago

Ok

Rajshah1897 commented 3 years ago

Now what is the next step after this? I can not see any front end samples in your prerequisite

image
mraible commented 3 years ago

That's it. That's the demo! Front end samples are at:

Rajshah1897 commented 3 years ago

Ok I got the error as below.

Error: Cannot find module 'dotenv' Require stack:

npm ERR! A complete log of this run can be found in: npm ERR! /Users/shahr/.npm/_logs/2020-09-16T19_50_59_123Z-debug.log shahr@US3RAPM0CD1EYMD samples-js-angular-master %

Rajshah1897 commented 3 years ago

@mraible can you please share the screenshots? how it looks like in UI? and what I am missing here? there is not enough information or may be I am missing something.

mraible commented 3 years ago

You need to run npm install first.

Rajshah1897 commented 3 years ago

Ok run npm install and it is successfully run now but how to connect front end samples and what is the front end file name? and how to run both in terminal?

image
mraible commented 3 years ago

It looks like you have the resource server running. Open a new terminal and cd into the “custom-login” directory. Then, run “npm start”.

On Sep 16, 2020, at 5:23 PM, Rajshah1897 notifications@github.com wrote:

Ok run npm install and it is successfully run now but how to connect front end samples and what is the front end file name? and how to run both in terminal?

https://user-images.githubusercontent.com/31449505/93402181-a56e6d00-f849-11ea-8fdc-34c290510d9f.png — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/okta/samples-nodejs-express-4/issues/93#issuecomment-693717891, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAELZHK6CC6P5AV75HBSGLSGFCGDANCNFSM4RPBB7UQ.

Rajshah1897 commented 3 years ago

Ok I did it and it was successfully run but when I checked localhost:8080 I got 400. Here is there screenshots as below.

Pease check testenv file are good?

1- customer-login

image

2.resource-server

image

Browser output

image
mraible commented 3 years ago

If you copy the link from your browser, you'll see the "redirect_uri" it's sending. Add that as a login redirect URI in your app and that should work. If it doesn't, please let us know.

On Sep 16, 2020, at 18:51, Rajshah1897 notifications@github.com wrote:

 Ok I did it and it was successfully run but when I checked localhost:8080 I got 400. Here is there screenshots as below.

Pease check testenv file are good?

1- customer-login

2.resource-server

Browser output

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

Rajshah1897 commented 3 years ago

No same thing I used that URI http://localhost:8080 after login my okta account it is showing me 400 error. Please find as below screenshots and also check the testenv file. should I need to create testenv file into both? resource-server and custom-login folder? and both should be same?

image image

system log

image
mraible commented 3 years ago

Can you copy / paste the URL from your browser when you see the error? Add it as a comment here please.

On Sep 16, 2020, at 19:09, Rajshah1897 notifications@github.com wrote:

 No same thing I used that URI http://localhost:8080 after login my okta account it is showing me 400 error. Please find as below screenshots and also check the testenv file. should I need to create testenv file into both? resource-server and custom-login folder? and both should be same?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

Rajshah1897 commented 3 years ago

https://dev-361462.okta.com/oauth2/default/v1/authorize?client_id=0oawwcug3oKESO5Wt4x6&code_challenge=qxx0OjU32jwCejVJqzY7feWZhSmNK4FPDcZ5N2sH1s8&code_challenge_method=S256&display=page&nonce=MwBbqfo7tw87DanNpAEHbIDz10J3WC3GywrEGuzI1TadCAB5FwGz86bplgxZYvcA&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Flogin%2Fcallback&response_mode=query&response_type=code&sessionToken=201117ravMGgXH63mtgLMXdEB5iwVSqtcJmld0-JqiPHXnngef_dUDT&state=BIU5hI1QcgbAsBJnfx0lRJfibjNU7GlZ7x8yyhOrQ7A1t01KpsufHhacvQUbNJbh&scope=openid%20profile%20email

also is this correct settings?

image
Rajshah1897 commented 3 years ago

Also let me know testenv files are ok or not for both folder? Is it same for both?

mraible commented 3 years ago

Can you try adding http://localhost:8080/login/callback http://localhost:8080/login/callback as a Login redirect URI for your Angular app on Okta?

On Sep 16, 2020, at 7:14 PM, Rajshah1897 notifications@github.com wrote:

Also let me know testenv files are ok or not for both folder? Is it same for both?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/okta/samples-nodejs-express-4/issues/93#issuecomment-693749069, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAELZCYJ3GGGUIAX5ITC3DSGFPJHANCNFSM4RPBB7UQ.

Rajshah1897 commented 3 years ago

The error as below after hitting this URL

image image

Also I am not understanding where I need to use this Issuer and client id and which file? because right now I just removed the testenv file from my current folder and there is no change if I am adding this or not adding this. Please write the all steps and how to config in resource-server and custom-login. it is kind of confusing.

**These values must exist as environment variables. They can be exported in the shell, or saved in a file named testenv, at the root of this repository. (This is the parent directory, relative to this README) See dotenv for more details on this file format.

ISSUER=https://yourOktaDomain.com/oauth2/default CLIENT_ID=123xxxxx123**

mraible commented 3 years ago

Does it work in an incognito window?

The steps that we currently have make sense to me. Can you please offer a suggestion about how to make them better?

On Sep 16, 2020, at 23:17, Rajshah1897 notifications@github.com wrote:

 The error as below after hitting this URL

Also I am not understanding where I need to use this Issuer and client id and which file? because right now I just removed the testenv file from my current folder and there is no change if I am adding this or not adding this. Please write the all steps and how to config in resource-server and custom-login. it is kind of confusing.

**These values must exist as environment variables. They can be exported in the shell, or saved in a file named testenv, at the root of this repository. (This is the parent directory, relative to this README) See dotenv for more details on this file format.

ISSUER=https://yourOktaDomain.com/oauth2/default CLIENT_ID=123xxxxx123**

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

Rajshah1897 commented 3 years ago

Yes it is working fine as below. Please confirm.

Also I have a questions about testenv that is still I am not getting I did not use that file in my current repository so how they will take my profile? did you do something at your end? and how?

Please find the screenshots as below.

image image

No testenv in my repository

image
mraible commented 3 years ago

The testenv file is in the custom-login's parent directory and the webpack configuration is smart enough to look there. If you didn't have this file there, it wouldn't work.

Rajshah1897 commented 3 years ago

Also I need to know how the same application work to generate the token? like machine to machine? Here we are tested with SPA. but I need to know machine to machine.

mraible commented 3 years ago

Please see Secure Server-to-Server Communication with Spring Boot and OAuth 2.0 for server-to-server.