# Angular. Environment variable issuer must be set

**URL:** <https://devforum.okta.com/t/angular-environment-variable-issuer-must-be-set/8532>\
**Category:** Questions\
**Created:** [March 19, 2020, 1:31pm UTC](https://devforum.okta.com/t/angular-environment-variable-issuer-must-be-set/8532 "2020-03-19T13:31:01Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![TermenVox](https://avatars.discourse-cdn.com/v4/letter/t/71e660/32.png) [@TermenVox](https://devforum.okta.com/u/TermenVox)\
**Post date:** [March 19, 2020, 1:31pm UTC](https://devforum.okta.com/t/angular-environment-variable-issuer-must-be-set/8532/1 "2020-03-19T13:31:01Z")

</div>

Hi all! I am studying [samples-js-angular](https://github.com/okta/samples-js-angular) and always get the same error:  
_ **An unhandled exception occurred: Environment variable ISSUER must be set. See README.md** _  
I tried to put `Client_Id` and `Issuer in` `environment.ts` like this:

```
export const environment = {
  production: false,
  ISSUER: "https://dev-843586.okta.com/oauth2/default",
  CLIENT_ID: "0oa48iu3oCyIWyO3I4x6"
};

```

It did not work.  
Then I tried to put them in `app.config.ts` like this:

```
export default {
  oidc: {
    clientId: "0oa48iu3oCyIWyO3I4x6",
    issuer: "https://dev-843586.okta.com/oauth2/default",
    redirectUri: 'http://localhost:8080/implicit/callback',
    scopes: ['openid', 'profile', 'email'],
    testing: {
      disableHttpsCheck: `${OKTA_TESTING_DISABLEHTTPSCHECK}`
    }
  },
  resourceServer: {
    messagesUrl: 'http://localhost:8000/api/messages',
  },
};

```

It did not help either.  
I still get the same error in terminal.  
What do I do wrong? Could anybody help me?

---

<div class="post-metadata">

**Author:** ![dragos](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/dragos/32/1313_2.png) [@dragos](https://devforum.okta.com/u/dragos)\
**Post date:** [March 20, 2020, 12:48am UTC](https://devforum.okta.com/t/angular-environment-variable-issuer-must-be-set/8532/2 "2020-03-20T00:48:01Z")

</div>

Hi @TermenVox

Can you please add a file called `testenv` (without any extensions) in the root directory (not inside /custom-login or /okta-hosted-login) with the following values:

```auto
ISSUER=https://your-okta-org-here.okta.com/oauth2/default
CLIENT_ID=your-client-id-here

```

---

<div class="post-metadata">

**Author:** ![TermenVox](https://avatars.discourse-cdn.com/v4/letter/t/71e660/32.png) [@TermenVox](https://devforum.okta.com/u/TermenVox)\
**Post date:** [March 20, 2020, 7:24am UTC](https://devforum.okta.com/t/angular-environment-variable-issuer-must-be-set/8532/3 "2020-03-20T07:24:34Z")

</div>

Thank you very much! It works!

---

<div class="post-metadata">

**Author:** ![antwaing](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@antwaing](https://devforum.okta.com/u/antwaing)\
**Post date:** [April 17, 2020, 1:07am UTC](https://devforum.okta.com/t/angular-environment-variable-issuer-must-be-set/8532/4 "2020-04-17T01:07:03Z")

</div>

testenv with no extension at all doesnt seem to work for me? I get same error

---

<div class="post-metadata">

**Author:** ![TermenVox](https://avatars.discourse-cdn.com/v4/letter/t/71e660/32.png) [@TermenVox](https://devforum.okta.com/u/TermenVox)\
**Post date:** [April 17, 2020, 7:43am UTC](https://devforum.okta.com/t/angular-environment-variable-issuer-must-be-set/8532/5 "2020-04-17T07:43:50Z")

</div>

Check if your `testnv` file is in the correct folder.  
For example, if your angular components are in the following route:  
`D:\Programming\mega_project\okta_test\src\app`  
then your `package.json` file lays in `okta_test` folder and `testnv` file must be in the `mega_project` folder.  
If you doubt - put `testnv` in all folders 😀  
Or just use workaround - in `app.config.ts` remove the following string  
`const { CLIENT_ID, ISSUER, OKTA_TESTING_DISABLEHTTPSCHECK } = process.env;`  
and hardcode your client id and issuer in the `oidc` object. Something like this:

```
export default {
  oidc: {
    clientId: "0oa48iu3oCyIWyO3I4x6",
    issuer: "https://dev-843586.okta.com/oauth2/default",
    redirectUri: 'http://localhost:8080/implicit/callback',
    scopes: ['openid', 'profile', 'email'],
  },
  resourceServer: {
    messagesUrl: 'http://localhost:8000/api/messages',
  },
};
```

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/oktadev/original/1X/589c4c5f80de422d01f47cee7185a7fb8227835c.png) [@system](https://devforum.okta.com/u/system)\
**Post date:** [January 23, 2024, 11:15pm UTC](https://devforum.okta.com/t/angular-environment-variable-issuer-must-be-set/8532/6 "2024-01-23T23:15:26Z")

</div>

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
