Error: Request principal is not authorized to use storage resource

Hi folks,

I’m trying to use the forge storage capability but I’m getting “Error: Request principal is not authorized to use storage resource” when I attempt to retrieve the property.

Here is the code:

const setProp = async () => {
	console.log('Setting property');
	await storage.set('example-key', 123);
}

const getProp = async () => {
	console.log('Getting property');
	const data = await storage.get('example-key');
	console.log(data);
	return data;
}    

const App = () => {	
   
  const context = useProductContext();
  	
  setProp();
  const [sampleprop] = useState(async () => await getProp());

Here is the manifest:

modules:
  jira:issuePanel:
    - key: hello-world-app-hello-world-panel
      function: main
      title: Compliance
      icon: https://developer.atlassian.com/platform/forge/images/icons/issue-panel-icon.svg
  function:
    - key: main
      handler: index.run
  
app:
  id: ari:cloud:ecosystem::app/acbea0ce-a585-483e-8373-8d09ff63f293

permissions:
  scopes:
    - 'storage:app'
    - 'read:jira-work'
    - 'write:jira-work'

Here is my output:

Error: Request principal is not authorized to use storage resource
    at Function.forErrorCode (webpack://forge-ui-starter/node_modules/@forge/storage/out/errors.js:33)
    at assertNoErrors (webpack://forge-ui-starter/node_modules/@forge/storage/out/global-storage.js:9)
    at getResponseBody (webpack://forge-ui-starter/node_modules/@forge/storage/out/global-storage.js:24)
    at async GlobalStorage.query (webpack://forge-ui-starter/node_modules/@forge/storage/out/global-storage.js:89)
    at async GlobalStorage.getInternal (webpack://forge-ui-starter/node_modules/@forge/storage/out/global-storage.js:75)
    at async getProp (webpack://forge-ui-starter/src/index.jsx:23)
    at async /tmp/tunnel78rvRfs2yu9OW/index.js:34681:88
    at async /tmp/tunnel78rvRfs2yu9OW/index.js:1591:21
    at async asyncMap (webpack://forge-ui-starter/node_modules/@forge/ui/out/reconcile.js:12)
    at async /tmp/tunnel78rvRfs2yu9OW/index.js:1543:29

Thanks for your assistance!

Hi @craig.schwarze,

I wasn’t able to reproduce this error. We can try two things here:

  1. Try reinstalling the app on your instance (maybe the storage permission wasn’t granted properly the first time)
  2. Look at your Network requests when the app is executing. Filter by graphql. Look for a request with mutation forge_ui_invokeAuxEffects in its query variable (image attached). Find x-trace-id in the headers and send it here so we can see what happened on the backend side of things :slight_smile: