arcgis-maps-sdk-swift-samples icon indicating copy to clipboard operation
arcgis-maps-sdk-swift-samples copied to clipboard

ArcGIS Maps SDK invalid API Key Error

Open pixlhero opened this issue 1 year ago • 5 comments

I created an API key with all the privileges and added it to the .secrets file. But I still get the error

ArcGIS Maps SDK invalid API Key Error: The API key '*j9CKE' is invalid, expired, or does not have access to the resource 'https://basemapstyles-api.arcgis.com/arcgis/rest/services/styles/v2/webmaps/arcgis/dark-gray'. Please visit https://developers.arcgis.com/api-keys to configure the API key to access the resource, or to create a new API key.

Is there anything I forgot?

Device: iPad (10th Gen) iPadOS 17.3.1 Xcode 15.4

pixlhero avatar Aug 14 '24 15:08 pixlhero

Thanks for asking the question. If you have configured the privileges correctly, it should just work so I'm not sure what's up here. 🤔

Do you have an Esri Community account? You can sign up and ping me via DM and we can try to figure it out there.

If you have a key that is known to be working for other applications, try that and compare result.

yo1995 avatar Aug 14 '24 16:08 yo1995

@pixlhero You can refer to this post, it also works for me. https://community.esri.com/t5/net-maps-sdk-questions/wpf-app-with-api-key-not-working/m-p/1516657

iamweijun avatar Aug 16 '24 02:08 iamweijun

@pixlhero You can refer to this post, it also works for me. https://community.esri.com/t5/net-maps-sdk-questions/wpf-app-with-api-key-not-working/m-p/1516657

That wasn't the issue, but thanks.

pixlhero avatar Aug 21 '24 14:08 pixlhero

ArcGIS Maps SDK invalid API Key Error: The API key '*j2Qde' is invalid, expired, or does not have access to the resource 'https://basemapstyles-api.arcgis.com/arcgis/rest/services/styles/v2/webmaps/arcgis/oceans'. Please visit https://developers.arcgis.com/api-keys to configure the API key to access the resource, or to create a new API key. Is there anything I forgot?

Device: iphone 15 pro (17.5) Xcode 15.4 SPM : 200.5.1

RakeshTylerTech avatar Nov 28 '24 08:11 RakeshTylerTech

ArcGIS Maps SDK invalid API Key Error: The API key '*j2Qde' is invalid, expired, or does not have access to the resource 'https://basemapstyles-api.arcgis.com/arcgis/rest/services/styles/v2/webmaps/arcgis/oceans'. Please visit https://developers.arcgis.com/api-keys to configure the API key to access the resource, or to create a new API key. Is there anything I forgot?

Device: iphone 15 pro (17.5) Xcode 15.4 SPM : 200.5.1

Can you either try creating a new API key following this tutorial, or go to the ArcGIS portal and check if the location services privileges are toggled on for your API key? Let me know the results as we are curious to see the root cause. Thank you!

Screenshot 2024-12-02 at 9 57 42 AM

yo1995 avatar Dec 02 '24 17:12 yo1995

I'm gonna close this issue as it's been sitting quiet for a while. In the future, if you want to test the key in the app, you can also temporarily hardcode the key in the @main entry point

ArcGISEnvironment.apiKey = .init("<#your-API-key#>")

yo1995 avatar Aug 06 '25 22:08 yo1995