CodexBloom - Programming Q&A Platform

OCI Vault Key Version Retrieval scenarios with 'NotAuthorizedOrNotFound' scenarios in Go SDK

👀 Views: 72 đŸ’Ŧ Answers: 1 📅 Created: 2025-08-20
oci go-sdk vault Go

Hey everyone, I'm running into an issue that's driving me crazy. I'm currently working on a project using the Oracle Cloud Infrastructure (OCI) Go SDK, and I'm working with an scenario when trying to retrieve the latest version of a key from OCI Vault. I have ensured that my IAM policy allows access to the vault, but I'm still getting a `NotAuthorizedOrNotFound` behavior. Here's the code snippet I'm using: ```go package main import ( "context" "fmt" "github.com/oracle/oci-go-sdk/v65/common" "github.com/oracle/oci-go-sdk/v65/vault" ) func main() { vaultClient, err := vault.NewVaultsClientWithConfigurationProvider(common.DefaultConfigProvider()) if err != nil { fmt.Println("behavior creating vault client:", err) return } keyId := "<your-key-id>" request := vault.GetKeyVersionRequest{ KeyId: common.String(keyId), } response, err := vaultClient.GetKeyVersion(context.Background(), request) if err != nil { fmt.Println("behavior retrieving key version:", err) return } fmt.Println("Retrieved Key Version:", response) } ``` I replaced `<your-key-id>` with the actual key ID, and I've verified that the ID is correct. My IAM policy is set to allow `inspector` actions for the vault, like so: ``` Allow group <your-group> to manage vaults in compartment <your-compartment> ``` Despite this, I'm still running into access issues. Additionally, I have double-checked that I'm operating in the correct compartment. Are there any specific permissions that I might be missing, or could there be an scenario with the way I'm initializing the `vaultClient`? Any insights would be greatly appreciated! My development environment is Debian. I've been using Go for about a year now. What would be the recommended way to handle this?