Connect to Real-Time Spotify Data in Power Apps Using Dataflows to Build Custom Applications
Power Apps is a suite of apps, services, and connectors that allows users to build custom applications with minimal or no coding. It empowers businesses to create tailored apps that solve specific business challenges, automate workflows, and integrate with various data sources, including Microsoft Dataverse, SQL Server, and third-party services.
Dataflows in Power Apps simplify the process of importing, transforming, and loading external data into Microsoft Dataverse or other storage systems. They allow users to connect to multiple data sources (like Salesforce, Excel, or SQL databases), clean or shape the data, and store it in Power Apps. When paired with the CData API Driver for Power BI, it provides access to Spotify data to build custom applications and more
This article demonstrates how you can easily connect to Spotify using the CData API Driver for Power BI and integrate your Spotify data through the Power Apps on-premises data gateway.
Configure a DSN to connect to Spotify data
Installing the Power BI Connector creates a DSN (data source name) called CData PBI Spotify Sys. This the name of the DSN that Power BI uses to request a connection to the data source. Configure the DSN by filling in the required connection properties.
You can use the Microsoft ODBC Data Source Administrator to create a new DSN or configure (and rename) an existing DSN: From the Start menu, enter "ODBC Data Sources." Ensure that you run the version of the ODBC Administrator that corresponds to the bitness of your Power BI Desktop installation (32-bit or 64-bit).
Using OAuth Authentication
Spotify uses OAuth 2.0 for authentication. You will need to create an application in the Spotify Developer Dashboard to obtain your client credentials.
Setting Up Your Spotify Application
- Visit the Spotify Developer Dashboard.
- Log in with your Spotify account and click Create app.
- Provide an app name, description, and set a Redirect URI (e.g.,
http://localhost:33333
for desktop applications). - Copy your Client ID and Client Secret from the app settings.
Connection Properties
After setting the following connection properties, you are ready to connect:
- AuthScheme: Set this to OAuth.
- InitiateOAuth: Set this to GETANDREFRESH. You can use InitiateOAuth to manage the process to obtain the OAuthAccessToken.
- OAuthClientId: Set this to your Spotify application's Client ID.
- OAuthClientSecret: Set this to your Spotify application's Client Secret.
- Scope: Set this to the required OAuth scopes (space-separated). The default includes all read scopes needed for the tables in this profile.
- CallbackURL: Set this to the Redirect URI configured in your Spotify application (e.g., http://localhost:33333).
Example Connection String
Profile=C:\profiles\Spotify.apip;AuthScheme=OAuth;InitiateOAuth=GETANDREFRESH;OAuthClientId=your_client_id;OAuthClientSecret=your_client_secret;CallbackURL=http://localhost:33333;
Available OAuth Scopes
- user-read-private: Read access to user's subscription details and explicit content settings.
- user-read-email: Read access to user's email address.
- user-library-read: Read access to a user's saved tracks, albums, episodes, shows, and audiobooks.
- playlist-read-private: Read access to user's private playlists.
- playlist-read-collaborative: Read access to collaborative playlists the user follows.
- user-follow-read: Read access to the list of artists the current user follows.
- user-read-playback-state: Read access to a user's player state (device, current track, progress).
- user-read-currently-playing: Read access to a user's currently playing content.
- user-read-playback-history: Read access to a user's recently played tracks.
- user-top-read: Read access to a user's top artists and tracks.
Configure the on-premises data gateway to recognize the CData API Driver for Power BI
In this section, we will configure the on-premises data gateway to detect the CData API Driver for Power BI installed on your system. If you haven't installed the data gateway yet, you can download it from Microsoft's official website.
Set Up the Power BI Gateway
Follow the given process to configure the on-premise data gateway on your machine:
- Download and install the on-premises data gateway (recommended) option.
- Sign into the gateway.
- Create a name for the new gateway and specify a recovery key.
- Open the new gateway, navigate to the Connector tab, and select the path C:\Program Files\CData\CData API Driver for Power BI from the folder. Click on Apply.
NOTE: Select the folder where the gateway will search for the CData Power BI Connector.
- Once the CData API Driver for Power BI is identified by the gateway, you're good to go.
Configure a dataflow connection in Power Apps
Once the on-premise data gateway is configured and a new gateway is created, follow these steps to create a dataflow that pulls in the Spotify data into Power Apps:
- Open Power Apps.
- Select Dataflows from the left panel on the Power Apps screen and click + New Dataflow.
- Provide a name to the dataflow and click Create.
- Select ODBC from the list of data sources.
- On the ODBC Connection settings screen, use the connection details you set up earlier by entering DSN=Connection name (in this case, DSN=CData PBI Spotify Sys) in the connection string. The on-premise data gateway will display available gateways for connection - select the one you created. Due to the current specifications of Power Apps dataflows, authentication is required for ODBC connections. Choose Basic as the authentication type and enter the Spotify Username and Password. Click Next.
- Spotify is now connected to Power Apps. Under Display options, expand CData under ODBC and Spotify under CData, and a list of all the Spotify tables will appear in the panel. When you select any one of these tables, a preview will appear, showing that the Spotify data is correctly referenced through the Power BI connector and on-premise data gateway. Next, click on Transform Data.
- On the query editing screen, if no column conversion is needed, you can skip this step and proceed by clicking on Next.
- In the Choose destination settings screen, you can select how the selected table needs to be loaded by choosing options like Load to new table, Load to existing table, and Do not load. You can also change the Table display name and description as required.
- Finally, choose how you'd like to update your data: Refresh manually or Refresh automatically. In this case, we have set it to Refresh automatically. By scheduling it to update every 45 minutes, as shown below, data will be collected and registered every 45 minutes timeframe, ensuring the most up-to-date information is always available. (You can select any timeframe based on your convenience)
- Click on Publish. The dataflow will now be created, published, and displayed as a part of the dataflow list on the Dataflows screen.
Get Started Today
At this point, you will have created a dataflow using live Spotify data and connected it to Power Apps. To learn more, explore the CData Power BI Connectors for Salesforce and download a free 30-day trial from the CData API Driver for Power BI page.
Feel free to reach out to our Support Team with any questions.