I have created netlify function for getting spotify access token using getSecrets and it works as it should on localhost returning all my spotify information. The problem comes when I deploy the site, because then the function just returns empty object.
Should I do any additional configuration for netlify Graph?
Click on the Site & Authentication option. Kindly read the information on the Site & Authentication options page and then configure it accordingly to your site.
After scroll down to the API Authentication section and then click Choose a service and select Spotify.
Make sure you enable the correct permissions and Scopes so that you can make requests to the API endpoints
After click on Enable to continue the process.
Your Site should now be connected to Spotify and you should now be able to start working with their API!
You can also find more information about connecting to an API service or Graph Authentication in the Official Netlify GitHub page link below.
Let me know if the above suggestions works or not.
Thanks.
I’ve already configured everything in your proposed solution. What is weird is that the site used to work correctly until 3 weeks ago and even now works correctly when being run with netlify-cli. I even redeployed the site in a new Netlify project but getSecrets() function didn’t work, so now I am really without any idea what I am doing wrong.
Hi @joze747, thanks for the feedback.
If it’s working on local development and not in production then something must be going wrong with your deployments.
At this point there could be so many reasons causing your current deployment not to work. It would be difficult to point out what might be causing the getSecrets function not to work.
However I just want to find out if you made any changes to your code before the time you stated that it worked correctly?
Secondly note that Authentication tokens are specific to each site. If you enable an API provider for a site, you can’t reuse the token on other sites. You need to authenticate with the same provider again for every site
When you have a moment, please let us know if you are still encountering this obstacle! @clarnx, thanks so much for all of the thorough suggestions here.
@joze747 if you follow @clarnx’s suggestions and are still having issues, please provide a reproduction for us so that we can look into the details further.
Hi @hillary, I have successfully solved the problem. I removed netlify-cli and updated @netlify/functions to newer version in package.json and I think one of those two was the solution.
Thank you so much for coming back and letting us know! This solution will help future Netlify forums members who encounter something similar. Happy building