0

I am creating an LWC component that utilizes the Spotify API auth flow to authorize a user's Spotify account and allows me to add playlists to their Spotify account directly from an LWC component with their permission.

I use the following URL to start the auth flow: https://accounts.spotify.com/en/authorize?&client_id=[_myAppsClientCode_]&response_type=code&redirect_uri=https://johngordoaudemysandbox-dev-ed.develop.lightning.force.com/lightning/n/Playground&scope=user-read-private%20user-read-email

And I receive this back from Spotify https://johngordoaudemysandbox-dev-ed.develop.lightning.force.com/lightning/n/Playground?**code=**[_returned_auth_code_]

However, since there is no namespace on the URL parameter it is chopped off when it loads.

When I manually type a namespace into the URL, the parameter remains in the URL without any issue: https://johngordoaudemysandbox-dev-ed.develop.lightning.force.com/lightning/n/Playground?**c__code=[returned_auth_code]**

I'm unsure where I can add the "c__" namespace to the "c__code=[returned_auth_code]" in the settings of ether Spotify's API or in my Salesforce org so that it appears in the returned URL automatically.

The googling I've done so far has led me toward SSO configuration. Can anyone provide insight or at least a set of keywords that I can google to get closer to the issue?

1
  • 1
    Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Commented Dec 11, 2022 at 23:02

1 Answer 1

0

OAuth protocol specifies that the parameter must be code. You can't fix this on the API end. What you can do, however, is write up a Visualforce page to catch the code parameter, then redirect from Visualforce to your Aura/LWC component with the parameter fixed up with the c__ prefix.

1
  • Thanks @sfdcfox ! Your suggestion worked, much appreciated.
    – A_Gordoa
    Commented Dec 12, 2022 at 18:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .