How to integrate oAuth login with a packaged electron app

前端 未结 1 1202
星月不相逢
星月不相逢 2021-01-28 04:37

I have been working on a new electron app with react that uses the Spotify API. I am using oAuth to authenticate with Spotify and a return an access token, this why fine in a lo

相关标签:
1条回答
  • 2021-01-28 04:49

    You can register custom protocol and intercept it via electron so that you dont require a web server. you may set the urn of the native desktop/mobile application instead of redirect uri of the web app.

    https://electronjs.org/docs/api/protocol

    protocol.registerFileProtocol('yourprotocolname', (request, callback) => {
    
          //parse authorization code from request 
    
      }, (error) => {
        if (error) console.error('Failed to register protocol')
      })
    

    Set the urn of the application in the oauth configuration as yourprotocolname://example

    0 讨论(0)
提交回复
热议问题