Building a Spotify web application Using APEX

 
Building a Spotify
web application
using APEX
 
André van der Put
30-9-2021
 
About me
 
Software developer at Open-Fine
Oracle developer since 1997
APEX developer since 2009
a.v.d.put@open-fine.nl
linkedin.com/in/andrevanderput/
 
 
30-9-2021
 
Building a Spotify web application using APEX
 
2
 
Why Spotify?
 
Has a REST API that uses authentication
Could also be Jira, LinkedIn, …
 
30-9-2021
 
Building a Spotify web application using APEX
 
3
 
Why this presentation?
 
APEX and Web Services
Documentation focuses on Oracle REST Data Services
Little to be found on APEX and external web services
APEX and authenticated external web services ???
 
30-9-2021
 
Building a Spotify web application using APEX
 
4
 
Overview
 
Apex REST Data Sources (formerly Web Source Modules)
Spotify Web API
OAuth2 flows
Examples ………
 
30-9-2021
 
Building a Spotify web application using APEX
 
5
 
Oracle Cloud Free Tier Autonomous Database
 
Call external web services from APEX
All web services must be secured. Only HTTPS services are supported
on the default port (443). 
Your Application Express instance is pre-
configured with an Oracle Wallet 
that contains more than 90 of the
most common trusted root and intermediate SSL certificates.
Each Autonomous Transaction Processing instance is preconfigured
with a network access control list (ACL) to permit outbound web
service calls from Application Express. 
No further configuration by
application developers is necessary.
 
30-9-2021
 
Building a Spotify web application using APEX
 
6
 
APEX REST Data Sources
 
No authentication, easy to create
Example: RSS feed
 
30-9-2021
 
Building a Spotify web application using APEX
 
7
 
APEX REST Data Sources
 
REST Data Source can be used in PL/SQL
e.g. to fill table with Web Source data
Use APEX_EXEC.OPEN_WEB_SOURCE_QUERY and
APEX_EXEC.NEXT_ROW
 
Since 20.2: Data Synchronization
 
30-9-2021
 
Building a Spotify web application using APEX
 
8
 
Spotify Web API
 
https://developer.spotify.com/documentation/web-api/reference/
64 web endpoints
Authorization via OAuth2
 
30-9-2021
 
Building a Spotify web application using APEX
 
9
 
Authorization
 
https://developer.spotify.com/documentation/general/guides/authori
zation-guide/
 
30-9-2021
 
Building a Spotify web application using APEX
 
10
 
OAuth2
 
Spotify uses 3 OAuth2 flows:
Client Credentials
Authorization Code
Implicit Grant (JavaScript client)
21 of the 64 web endpoints are accessible via Client Credentials
APEX only supports Client Credentials
 
30-9-2021
 
Building a Spotify web application using APEX
 
11
 
Client Credentials flow
 
30-9-2021
 
Building a Spotify web application using APEX
 
12
 
Client Credentials in Spotify
 
30-9-2021
 
Building a Spotify web application using APEX
 
13
 
https://developer.spotify.com/dashboard/applications
Create a client ID
 
Client Credentials in APEX
 
Authentication in REST Data Source
Example: Get Categories
 
30-9-2021
 
Building a Spotify web application using APEX
 
14
 
Example: Get Categories
 
GET 
https://api.spotify.com/v1/browse/categories
 
30-9-2021
 
Building a Spotify web application using APEX
 
15
    {
       "categories": 
{
           "items": 
[
              {
 
  "id": "toplists"
,
 
  "name": "Top Lists"
              
},
              {
 
  "id": "hiphop"
,
 
  "name": "Hip Hop"
        
      
},
 
.....
 
.....
 
]
         }
    }
 
Authorization Code flow
 
User login and approval
Scopes
Callback URL
Refresh token
 
 
30-9-2021
 
Building a Spotify web application using APEX
 
16
 
30-9-2021
 
Building a Spotify web application with APEX
 
17
 
Authorization Code in APEX
 
2 options
Use Social Sign-in function of APEX
(Almost) no coding
APEX authentication through Spotify account
No refresh token
 
Create your own code
Use any APEX authentication
Refresh token available
 
 
 
30-9-2021
 
Building a Spotify web application using APEX
 
18
 
Authorization Code in Spotify (option 1)
 
Register Callback URL
From APEX API package:
apex_authentication.callback
 
30-9-2021
 
Building a Spotify web application using APEX
 
19
 
Authorization Code in APEX (option 1)
 
Create Authentication Scheme
Type: Social Sign-In
Credentials in Credential Store
(client_id and client_secret)
 
30-9-2021
 
Building a Spotify web application using APEX
 
20
 
Authorization Code in APEX (option 1)
 
Get Access token in
Post-Authentication Procedure
 
30-9-2021
 
Building a Spotify web application using APEX
 
21
 
Authorization Code in APEX
 
Make requests to the Spotify Web API
REST Data Source with access token in Authorization header
 
Example: 
Get a List of Current User's Playlists
 
30-9-2021
 
Building a Spotify web application using APEX
 
22
 
Example: 
Get a List of Current User's Playlists
 
GET 
https://api.spotify.com/v1/me/playlists
 
 
 
30-9-2021
 
Building a Spotify web application with APEX
 
23
{
    
"href"
:
 
"https://api.spotify.com/v1/users/wizzler/playlists"
,
    
"items"
:
 
[
        
{
            
"id"
:
 
"53Y8wT46QIMz5H4WQ8O22c"
,
            "name"
:
 
"Wizzlers Big Playlist"
,
            "tracks"
:
 
{
 
"href"
:
 
,
 
"total"
:
 
30
 
},
            
"type"
:
 
"playlist"
,
 },
    
 
],
    
"limit"
:
 
9
,
    
"next"
:
 
null
,
    
"offset"
:
 
0
,
    
"previous"
:
 
null
,
    
"total"
:
 
9
}
 
Authorization Code in APEX (option 2)
 
Callback URL
Three parameters: code, state and error
Can be made via ORDS
 
 
 
 
30-9-2021
 
Building a Spotify web application using APEX
 
24
 
Authorization Code in Spotify (option 2)
 
Register Callback URL
 
30-9-2021
 
Building a Spotify web application using APEX
 
25
 
Authorization Code in APEX (option 2)
 
Make request to the Spotify accounts service to get tokens
Via APEX_WEB_SERVICE.MAKE_REST_REQUEST
 
 
 
 
 
Reconnect to APEX session
 
30-9-2021
 
Building a Spotify web application using APEX
 
26
{
 
"access_token"
: 
"NgCXRK...MzYjw"
,
 
"token_type"
: 
"Bearer"
,
 
"scope"
: 
"user-read-private user-read-email"
,
 
"expires_in"
: 
3600
,
 
"refresh_token"
: 
"NgAagA...Um_SHo"
}
 
Authorization Code in APEX (option 2)
 
Call authorize service, parameters:
 
client_id
      
redirect URL (callback)
      
scope
      
state (APEX session ID)
In callback procedure:
 
call token URL, parameters: 
 
code
         
client_id
         
client_secret
    
store retrieved tokens in table, key: session ID
    
redirect to APEX session using session ID
Call web API’s using access token
 
30-9-2021
 
Building a Spotify web application using APEX
 
27
 
Authorization Code in APEX (option 2)
 
Refresh token
Make request to the Spotify accounts service
Via APEX_WEB_SERVICE.MAKE_REST_REQUEST
 
Refresh token in POST
Client ID and Client Secret BASE64 encoded in Header
 
 
 
30-9-2021
 
Building a Spotify web application using APEX
 
28
 
30-9-2021
 
Building a Spotify web application using APEX
 
  
29
 
Summary
 
Client credentials flow
REST Data Sources
No coding necessary
 
Authorization code flow
Use Social Sign-in
   
No coding necessary for authorization
     
Limited session length (1 hour)
Create custom callback code
 
Coding required for authorization
     
Indefinite session length
 
 
 
30-9-2021
 
Building a Spotify web application using APEX
 
30
 
Questions?
Slide Note
Embed
Share

This presentation focuses on integrating Spotify's REST API with Oracle APEX, showcasing OAuth2 flows, data synchronization, and utilizing APEX REST Data Sources to create a secure and user-friendly web application.

  • Spotify
  • APEX
  • REST API
  • Web Application
  • OAuth2

Uploaded on Mar 03, 2025 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. Building a Spotify web application using APEX Andr van der Put 30-9-2021

  2. About me Software developer at Open-Fine Oracle developer since 1997 APEX developer since 2009 a.v.d.put@open-fine.nl linkedin.com/in/andrevanderput/ 2 30-9-2021 Building a Spotify web application using APEX

  3. Why Spotify? Has a REST API that uses authentication Could also be Jira, LinkedIn, 3 30-9-2021 Building a Spotify web application using APEX

  4. Why this presentation? APEX and Web Services Documentation focuses on Oracle REST Data Services Little to be found on APEX and external web services APEX and authenticated external web services ??? 4 30-9-2021 Building a Spotify web application using APEX

  5. Overview Apex REST Data Sources (formerly Web Source Modules) Spotify Web API OAuth2 flows Examples 5 30-9-2021 Building a Spotify web application using APEX

  6. Oracle Cloud Free Tier Autonomous Database Call external web services from APEX All web services must be secured. Only HTTPS services are supported on the default port (443). Your Application Express instance is pre- configured with an Oracle Wallet that contains more than 90 of the most common trusted root and intermediate SSL certificates. Each Autonomous Transaction Processing instance is preconfigured with a network access control list (ACL) to permit outbound web service calls from Application Express. No further configuration by application developers is necessary. 6 30-9-2021 Building a Spotify web application using APEX

  7. APEX REST Data Sources No authentication, easy to create Example: RSS feed 7 30-9-2021 Building a Spotify web application using APEX

  8. APEX REST Data Sources REST Data Source can be used in PL/SQL e.g. to fill table with Web Source data Use APEX_EXEC.OPEN_WEB_SOURCE_QUERY and APEX_EXEC.NEXT_ROW Since 20.2: Data Synchronization 8 30-9-2021 Building a Spotify web application using APEX

  9. Spotify Web API https://developer.spotify.com/documentation/web-api/reference/ 64 web endpoints Authorization via OAuth2 9 30-9-2021 Building a Spotify web application using APEX

  10. Authorization https://developer.spotify.com/documentation/general/guides/authori zation-guide/ 10 30-9-2021 Building a Spotify web application using APEX

  11. OAuth2 Spotify uses 3 OAuth2 flows: Client Credentials Authorization Code Implicit Grant (JavaScript client) 21 of the 64 web endpoints are accessible via Client Credentials APEX only supports Client Credentials 11 30-9-2021 Building a Spotify web application using APEX

  12. Client Credentials flow 12 30-9-2021 Building a Spotify web application using APEX

  13. Client Credentials in Spotify https://developer.spotify.com/dashboard/applications Create a client ID 13 30-9-2021 Building a Spotify web application using APEX

  14. Client Credentials in APEX Authentication in REST Data Source Example: Get Categories 14 30-9-2021 Building a Spotify web application using APEX

  15. Example: Get Categories GET https://api.spotify.com/v1/browse/categories { "categories": { "items": [ { "id": "toplists", "name": "Top Lists" }, { "id": "hiphop", "name": "Hip Hop" }, ..... ..... ] } } 15 30-9-2021 Building a Spotify web application using APEX

  16. Authorization Code flow User login and approval Scopes Callback URL Refresh token 16 30-9-2021 Building a Spotify web application using APEX

  17. 17 30-9-2021 Building a Spotify web application with APEX

  18. Authorization Code in APEX 2 options Use Social Sign-in function of APEX (Almost) no coding APEX authentication through Spotify account No refresh token Create your own code Use any APEX authentication Refresh token available 18 30-9-2021 Building a Spotify web application using APEX

  19. Authorization Code in Spotify (option 1) Register Callback URL From APEX API package: apex_authentication.callback 19 30-9-2021 Building a Spotify web application using APEX

  20. Authorization Code in APEX (option 1) Create Authentication Scheme Type: Social Sign-In Credentials in Credential Store (client_id and client_secret) 20 30-9-2021 Building a Spotify web application using APEX

  21. Authorization Code in APEX (option 1) Get Access token in Post-Authentication Procedure 21 30-9-2021 Building a Spotify web application using APEX

  22. Authorization Code in APEX Make requests to the Spotify Web API REST Data Source with access token in Authorization header Example: Get a List of Current User's Playlists 22 30-9-2021 Building a Spotify web application using APEX

  23. Example: Get a List of Current User's Playlists GET https://api.spotify.com/v1/me/playlists { "href": "https://api.spotify.com/v1/users/wizzler/playlists", "items": [ { "id": "53Y8wT46QIMz5H4WQ8O22c", "name": "Wizzlers Big Playlist", "tracks": { "href": , "total": 30 }, "type": "playlist", }, ], "limit": 9, "next": null, "offset": 0, "previous": null, "total": 9 } 23 30-9-2021 Building a Spotify web application with APEX

  24. Authorization Code in APEX (option 2) Callback URL Three parameters: code, state and error Can be made via ORDS 24 30-9-2021 Building a Spotify web application using APEX

  25. Authorization Code in Spotify (option 2) Register Callback URL 25 30-9-2021 Building a Spotify web application using APEX

  26. Authorization Code in APEX (option 2) Make request to the Spotify accounts service to get tokens Via APEX_WEB_SERVICE.MAKE_REST_REQUEST { } "access_token": "NgCXRK...MzYjw", "token_type": "Bearer", "scope": "user-read-private user-read-email", "expires_in": 3600, "refresh_token": "NgAagA...Um_SHo" Reconnect to APEX session 26 30-9-2021 Building a Spotify web application using APEX

  27. Authorization Code in APEX (option 2) Call authorize service, parameters: In callback procedure: Call web API s using access token client_id redirect URL (callback) scope state (APEX session ID) call token URL, parameters: store retrieved tokens in table, key: session ID redirect to APEX session using session ID code client_id client_secret 27 30-9-2021 Building a Spotify web application using APEX

  28. Authorization Code in APEX (option 2) Refresh token Make request to the Spotify accounts service Via APEX_WEB_SERVICE.MAKE_REST_REQUEST Refresh token in POST Client ID and Client Secret BASE64 encoded in Header 28 30-9-2021 Building a Spotify web application using APEX

  29. Summary Client credentials flow REST Data Sources No coding necessary Authorization code flow Use Social Sign-in Create custom callback code No coding necessary for authorization Limited session length (1 hour) Coding required for authorization Indefinite session length 29 30-9-2021 Building a Spotify web application using APEX

  30. Questions? 30 30-9-2021 Building a Spotify web application using APEX

More Related Content

giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#