samples-nodejs-express-4 icon indicating copy to clipboard operation
samples-nodejs-express-4 copied to clipboard

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

Open Rajshah1897 opened this issue 4 years ago • 28 comments

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

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

Rajshah1897 avatar Sep 16 '20 15:09 Rajshah1897

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

mraible avatar Sep 16 '20 19:09 mraible

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

Rajshah1897 avatar Sep 16 '20 19:09 Rajshah1897

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

mraible avatar Sep 16 '20 19:09 mraible

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

Rajshah1897 avatar Sep 16 '20 19:09 Rajshah1897

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

mraible avatar Sep 16 '20 19:09 mraible

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

Rajshah1897 avatar Sep 16 '20 19:09 Rajshah1897

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

mraible avatar Sep 16 '20 19:09 mraible

Ok

Rajshah1897 avatar Sep 16 '20 19:09 Rajshah1897

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

image

Rajshah1897 avatar Sep 16 '20 19:09 Rajshah1897

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

  • https://github.com/okta/samples-js-angular
  • https://github.com/okta/samples-js-react
  • https://github.com/okta/samples-js-vue

mraible avatar Sep 16 '20 19:09 mraible

Ok I got the error as below.

Error: Cannot find module 'dotenv' Require stack:

  • /Users/shahr/Downloads/samples-js-angular-master/scripts/startResourceServer.js at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15) at Function.Module._load (internal/modules/cjs/loader.js:841:27) at Module.require (internal/modules/cjs/loader.js:1025:19) at require (internal/modules/cjs/helpers.js:72:18) at Object. (/Users/shahr/Downloads/samples-js-angular-master/scripts/startResourceServer.js:6:16) at Module._compile (internal/modules/cjs/loader.js:1137:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10) at Module.load (internal/modules/cjs/loader.js:985:32) at Function.Module._load (internal/modules/cjs/loader.js:878:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) { code: 'MODULE_NOT_FOUND', requireStack: [ '/Users/shahr/Downloads/samples-js-angular-master/scripts/startResourceServer.js' ] } npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! @okta/[email protected] resource-server: node scripts/startResourceServer.js npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the @okta/[email protected] resource-server script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm WARN Local package.json exists, but node_modules missing, did you mean to install?

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 avatar Sep 16 '20 19:09 Rajshah1897

@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.

Rajshah1897 avatar Sep 16 '20 20:09 Rajshah1897

You need to run npm install first.

mraible avatar Sep 16 '20 21:09 mraible

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

Rajshah1897 avatar Sep 16 '20 23:09 Rajshah1897

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 [email protected] 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.

mraible avatar Sep 17 '20 00:09 mraible

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

Rajshah1897 avatar Sep 17 '20 00:09 Rajshah1897

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 [email protected] 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.

mraible avatar Sep 17 '20 00:09 mraible

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

Rajshah1897 avatar Sep 17 '20 01:09 Rajshah1897

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 [email protected] 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.

mraible avatar Sep 17 '20 01:09 mraible

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 avatar Sep 17 '20 01:09 Rajshah1897

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

Rajshah1897 avatar Sep 17 '20 01:09 Rajshah1897

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 [email protected] 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.

mraible avatar Sep 17 '20 04:09 mraible

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**

Rajshah1897 avatar Sep 17 '20 05:09 Rajshah1897

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 [email protected] 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.

mraible avatar Sep 17 '20 05:09 mraible

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

Rajshah1897 avatar Sep 17 '20 14:09 Rajshah1897

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.

mraible avatar Sep 17 '20 17:09 mraible

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.

Rajshah1897 avatar Sep 17 '20 17:09 Rajshah1897