Showing posts with label spotify-app. Show all posts
Showing posts with label spotify-app. Show all posts

Tuesday, September 26, 2017

Spotify SDK Missing token refresh service?

Leave a Comment

i am trying to void popup grant permission for user every time session expired in Spotify for SDK , after one hour maybe a popup appear to grant permission again to user so he can play tracks from Spotify on my app , the Error i am getting when try to renew the session :

[PLAYER][PLAY][SPOTIFY] Error renew Session Optional(Error Domain=com.spotify.auth Code=0 "Missing token refresh service." UserInfo={NSLocalizedDescription=Missing token refresh service.}) [PLAYER][SPOTIFY] Session could not be renewed,popup login 

and here how i am trying to renew the session :

//Renew Session func renewSession(completion:@escaping (Bool)->()) {     print("[PLAYER][PLAY][SPOTIFY] Renew Session requested ")      let auth = SPTAuth.defaultInstance()         auth?.renewSession(auth?.session, callback: { (error, session) in              if (error != nil)             {                 print("[PLAYER][PLAY][SPOTIFY] Error renew Session \(String(describing: error))")                 completion(false)                 return             }              auth?.session = session              if auth?.session.isValid() == true             {                 print("[PLAYER][PLAY][SPOTIFY] Renew Session Success")                 completion(true)             }else             {                 print("[PLAYER][PLAY][SPOTIFY] Renew Session Failed")                 completion(false)             }     })  } 

any solution for this ?

1 Answers

Answers 1

Have you assigned these properties on your SPTAuth object?

[SPTAuth defaultInstance].tokenSwapURL = [NSURL URLWithString:@"swapURL"]; [SPTAuth defaultInstance].tokenRefreshURL = [NSURL URLWithString:@"refreshURL"];

Taken from https://github.com/spotify/ios-sdk/issues/427 which might have more info if that isn't sufficient.

There's also a reference for the SPTAuth class:

https://spotify.github.io/ios-sdk/Classes/SPTAuth.html

Read More

Tuesday, April 26, 2016

Spotify Auth + Angular + Client Credential Flow

Leave a Comment

Using these information
https://developer.spotify.com/web-api/authorization-guide

I am trying to implement the 'Client Credentials Flow' to automate the authentication process. But somehow I got the error below.

XMLHttpRequest cannot load https://accounts.spotify.com/api/token?grant_type=client_credentials. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'websiteURL' is therefore not allowed access.

    $http.get('https://accounts.spotify.com/api/token?grant_type=client_credentials', {         headers: {             'Authorization': 'Basic ' + key)         }     }).success(function(r) {         console.log('got access token', r);     }).error(function(err) {         console.log('failed to get access token', err);      });      

I have also tried it via Ajax / Jquery and other methods but still have this one 'Access-Control-Allow-Origin'.

I have read a lot of stuffs regarding this about CORS, Angular, Node, etc. And honestly I'm confused which of these should I use and I don't have an idea how to. Can someone simplify this for me please?

1 Answers

Answers 1

This is not the flow you're looking for - The Client Credential flow is meant for communication between servers.

Instead, have a look at the Authorization Code Flow, and why not Jose Perez's excellent JavaScript wrapper for front-ends working with Spotify's Web API.

This flow allows your application's users to authenticate and authorize your application to act on their behalf (e.g. add tracks to playlists, create playlists, and so forth). Access tokens retrieved using the Client Credentials flow isn't connected to a specific user, which limits what your application can do using it.

Read More