terraform-provider-okta: Okta Generated Private Key Not working in Terrform Provider

    > Hi, @simonweil! Thanks for submitting this issue!
  1. API token can be created using admin Okta console Security > API > Tokens Crete Token. API tokens inherit the privilege level of the admin account that is used to create them
  2. Using client_id, scopes and private_key can give more granular access to the org resources. Basically, caller exchange client_id, scopes and private_key for Bearer token and use it to make API calls. You can read more about this type of auth here.

This is simplified example of how to create and use access token:

  1. Generate JWK using this https://mkjwk.org/
  2. Convert it to private/public keys using this https://8gwifi.org/jwkconvertfunctions.jsp
  3. Add JWK key to service app
  4. Grand necessary scopes in Okta API Scopes in that app.
  5. Config sample:
provider "okta" {
  org_name  = "my-org"
  base_url  = "okta.com"
  private_key = file("a.pem") // this is the file with the private key
  client_id = "0oazdwjh3wTJdfeRW0h7" // clientID from the service app
  scopes = ["okta.apps.manage", "okta.users.read", "okta.users.manage", "okta.policies.manage", "okta.groups.manage"]
}
  1. Run terraform

Above steps worked for me but If we generate-the-jwk-using-the-admin-console and use the same in PEM format i am getting below error . https://developer.okta.com/docs/guides/implement-oauth-for-okta-serviceapp/main/#generate-the-jwk-using-the-admin-console PEM File Format : -----BEGIN PRIVATE KEY----- XXXXXX -----END PRIVATE KEY-----

Error: failed to get SAML application: RSA private key is of the wrong type

_Originally posted by @dbshelke in https://github.com/okta/terraform-provider-okta/issues/892#issuecomment-1277446861_

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15

Most upvoted comments

We made the provider be flexible with using PKCS#1 or PKCS#8 private key formats without the operator having to do any conversion. I’m going to close issue as done.

https://github.com/okta/terraform-provider-okta/releases/tag/v4.4.3