Comments (9)
Following up… by all indications the app should be able to authenticate without the tokenSwapURL
and tokenRefreshURL
endpoints and get an access token that expires in an hour. And it seems like it almost works— if I break in application(_, open url, options)
and peek at the incoming URL, it appears to have a valid access code:
myapp-spt://?code=AQCjw-6KFlBA532RvD1XrBbTwcgoZSQjCF0bSi2_ihDQuHBLAHBLAH
The problem is that afterward the call to sessionManager.application(app, open: url, options: options)
for some reason is generating a sessionManager(didFailWith)
error on the delegate. I've triple checked that my app's callback URI on the dashboard matches what's in the app and Info.plist (and they were working with the older framework).
The exact same thing happens in the Obj-C sample app if I comment out the lines that set the tokenSwapURL
and tokenRefreshURL
.
from ios-sdk.
You should use "the built-in app-remote-control Authorization flow" to avoid using tokenSwapURL and tokenRefreshURL and get an one hour access token.
Do not use STPSessionManager. Just STPAppRemote:
SPTConfiguration *configuration =
[[SPTConfiguration alloc] initWithClientID:@"your_client_id" redirectURL:[NSURL urlWithString:@"your_redirect_uri"]];
self.appRemote =
[[SPTAppRemote alloc] initWithConfiguration:configuration logLevel:SPTAppRemoteLogLevelDebug];
BOOL spotifyInstalled = [self.appRemote authorizeAndPlayURI:@""]; // blank URI plays the last user song
Configure your AppDelegate to parse out the accessToken in application:openURL:options: and set it on the SPTAppRemote connectionParameters.
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
NSDictionary *params = [self.appRemote authorizationParametersFromURL:url];
NSString *token = params[SPTAppRemoteAccessTokenKey];
if (token) {
self.appRemote.connectionParameters.accessToken = token;
} else if (params[SPTAppRemoteErrorDescriptionKey]) {
NSLog(@"%@", params[SPTAppRemoteErrorDescriptionKey]);
}
return YES;
}
from ios-sdk.
@jscalo, @weswes is correct. You do not need a backend server if you using the the built-in app-remote-control Authorization flow
on SPTAppRemote
.
If you need any additional scopes you will need to set up a backend server to perform the token swap.
from ios-sdk.
Thanks @jackfreeman and @weswes, I'll give it a shot. Mind pointing me to where this is documented? I don't see it in any of the iOS guides or the Authorization guide.
from ios-sdk.
from ios-sdk.
Thanks @jackfreeman. One last question— the server flow can take a configuration with a nil playURI so that no audio plays after authentication. However in this flow the only way to start the auth process is with authorizeAndPlayURI
which takes a non-nil URI, so that audio always plays after authenticating. Is there any way to prevent that?
from ios-sdk.
@jscalo Unfortunately the only way to auth without playing music is by using SPTSessionManager
and setting up your own backend to handle the token swap.
from ios-sdk.
Weird. OK. Sending a bogus URI won't have the same effect?
from ios-sdk.
When the given access token through appDelegate openURL method by the built-in authorization expires, what can we do? Do we receive a new access token when calling appRemote.connect()? Or only when we call authorizeAndPlayURI? depending on whether the Spotify app is playing music or not
from ios-sdk.
Related Issues (20)
- iOS SDK Disconnect when app goes to background
- Wrong access token return
- Unable to activate repeat/shuffle mode HOT 1
- iOS SDK Disconnect when no playback
- Spotify does not redirect back to app
- Will there be an exemplar for SwiftUI for the iOS SDK for Spotify in the near future?
- Getting 403 "Insufficient client scope" creating playlist, even with playlist-read|modify-private
- Session Manager fails to initiate session since updating to XCode 15.2
- Used to be able to auth with player, now no longer can. HOT 7
- Privacy Manifest HOT 1
- https://github.com/DemoProjects/NowPlayingView/NowPlayingView/My-Extensions.swift
- Umbrella Header Warnings in v1.2.5 XCFramework
- Please add current position in context queue to SPTAppRemotePlayerState
- Illegal Scope Issues
- Feature Request: Authorise and play URI with trackIndex
- Spotify app refuses app connection attempts after switching Spotify account
- Dynamic Island Lyric App
- Spotify authorizes correctly using `SPTSessionManager` but never connects to `SPTAppRemote` HOT 1
- universal links to spotify-action://authorize?
- .
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ios-sdk.