Announcements

Help Wizard

Step 1

NEXT STEP

FAQs

Please see below the most popular frequently asked questions.

Loading article...

Loading faqs...

VIEW ALL

Ongoing Issues

Please see below the current ongoing issues which are under investigation.

Loading issue...

Loading ongoing issues...

VIEW ALL

Unable to Authorize Users with iOS SDK - NSCocoaErrorDomain Code=3840

Unable to Authorize Users with iOS SDK - NSCocoaErrorDomain Code=3840

My Question or Issue

 

I am using one of the earliest version of the Spotify iOS SDK that doesn't use the app remote calls. Most recently, my app users are no longer able to be authorized. Once their session and token are expired and an attempt to renew the token fails, I create a SPTAuth instance and attempt to create a login URL to enable them to login with the following code. 

 

NSURL *loginURL = [SPTAuth loginURLForClientId:kClientId

                                   withRedirectURL:[NSURL URLWithString:kCallbackURL]  scopes:@[SPTAuthStreamingScope, SPTAuthPlaylistModifyPrivateScope, SPTAuthPlaylistModifyPublicScope, SPTAuthUserLibraryReadScope, SPTAuthUserLibraryModifyScope, SPTAuthUserReadPrivateScope]

                                      responseType:@"code"];

 

Once making this call to create the loginURL, I receive a callback in my app delegate:

 

-(BOOL)application:(UIApplication *)application

           openURL:(NSURL *)url

           options:

 

I then process this callback by calling my token swap service on my server to get a logged in session with the following code:

 

    SPTAuth *auth = [SPTAuth defaultInstance];

    auth.tokenSwapURL = [NSURL URLWithString:kTokenSwapURL];

    [auth handleAuthCallbackWithTriggeredAuthURL:url callback:^(NSError *error, 

SPTSession *session) {

           if (error) {

              NSLog(@"Error: %@", error);

           }

}

 

I receive an error as follows:

 

Error Domain=NSCocoaErrorDomain Code=3840 "JSON text did not start with array or object and option to allow fragments not set. around line 2, column 1." UserInfo={NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set. around line 2, column 1., NSJSONSerializationErrorIndex=2}

 

What does this error mean?

What might be causing this to suddenly fail? No change has occurred on my end in over a year, yet I and my users are suddenly failing to be authorized.

 

Reply
0 Replies

Suggested posts

Staff
Let's introduce ourselves!

Hey there you,   Yeah, you! 😁   Welcome - we're glad you joined the Spotify Community!   While you here, let's have a fun game and get…

Staff
ModeratorStaff / Moderator/ 3 years ago  in Social & Random

Type a product name