I am building a project with both a web app built with React and Next.js and a native app built with React Native. I am looking for a second opinion on the best practice to handle Authorization for the Spotify API that will work on both platforms.
Option 1: Use the Authorization Code Flow with a proxy server to protect the client secret.
- Native app passes authorization
code
to proxy server on heroku usingGET
request - Proxy server passes
code
,redirect_uri
,grant_type
,client_id
, andclient_secret
to Spotify API - Proxy server passes back
access_token
,refresh_token
, andexpires_in
to either web app or native app
- Native app passes authorization
Option 2: Use the Implicit Grant flow and accept that there is no
refresh_token
. I would like to avoid this option if possible because the app will be making many requests and it would be more convenient to operate with arefresh_token
.
My main concern is keeping the client_secret
safe since my understanding is that React and React Native do not make requests server-side. Is it safe to pass back the access_token
and refresh_token
for a proxy?