[GH-ISSUE #295] Instagram login error: serverError("No access_token, no code and no error provided by server") #175

Closed
opened 2026-03-03 16:46:24 +03:00 by kerem · 2 comments
Owner

Originally created by @brdimattia on GitHub (Oct 18, 2016).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/295

Description: Instagram login not working returns an error:

serverError("No access_token, no code and no error provided by server")

after login and callback through heroku redirect

full code below:

let oioswift = OAuth2Swift(
            consumerKey:    "********",
            consumerSecret: "*******",
            authorizeUrl:   "https://api.instagram.com/oauth/authorize",
            responseType:   "token"
        )

        let state = generateState(withLength: 20)
        oioswift.authorizeURLHandler = SafariURLHandler(viewController: self, oauthSwift: oioswift)
        let _ = oioswift.authorize(
            withCallbackURL: URL(string: "https://herokuappsitename.herokuapp.com/")!, scope: "relationships", state:state,
            success: { credential, response, parameters in
                print("Authenticted with Service <Instagram>")
            },
            failure: { error in
                print("Instagram error is: " , error)
            }
        )

OAuth Provider (Twitter, Github, ..):

Instagram

OAuth Version:

  • Version 1
  • Version 2

OS (Please fill the version) :

  • iOS :
  • OSX :
  • TVOS :
  • WatchOS :

Installation method:

  • Carthage
  • CocoaPods
  • Manually

Library version:

  • head
  • v1.0.0
  • v0.6
  • other: (Please fill in the version you are using.)

Xcode version:

  • 8.0 (Swift 3.0)
  • 8.0 (Swift 2.3)
  • 7.3.1
  • other: (Please fill in the version you are using.)
  • objective c
Originally created by @brdimattia on GitHub (Oct 18, 2016). Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/295 ### Description: Instagram login not working returns an error: serverError("No access_token, no code and no error provided by server") after login and callback through heroku redirect full code below: ``` let oioswift = OAuth2Swift( consumerKey: "********", consumerSecret: "*******", authorizeUrl: "https://api.instagram.com/oauth/authorize", responseType: "token" ) let state = generateState(withLength: 20) oioswift.authorizeURLHandler = SafariURLHandler(viewController: self, oauthSwift: oioswift) let _ = oioswift.authorize( withCallbackURL: URL(string: "https://herokuappsitename.herokuapp.com/")!, scope: "relationships", state:state, success: { credential, response, parameters in print("Authenticted with Service <Instagram>") }, failure: { error in print("Instagram error is: " , error) } ) ``` ### OAuth Provider (Twitter, Github, ..): Instagram ### OAuth Version: - [ ] Version 1 - [x] Version 2 ### OS (Please fill the version) : - [x] iOS : - [ ] OSX : - [ ] TVOS : - [ ] WatchOS : ### Installation method: - [ ] Carthage - [ ] CocoaPods - [x] Manually ### Library version: - [ ] head - [ ] v1.0.0 - [ ] v0.6 - [ ] other: (Please fill in the version you are using.) ### Xcode version: - [x] 8.0 (Swift 3.0) - [ ] 8.0 (Swift 2.3) - [ ] 7.3.1 - [ ] other: (Please fill in the version you are using.) - [ ] objective c
kerem 2026-03-03 16:46:24 +03:00
Author
Owner

@phimage commented on GitHub (Oct 18, 2016):

Somewhere in your code you must have done " OAuthSwift.handle(url: )"
The url is from provider redirection which add some info to your callbackurl
Can you check the value of this url. The query of this url must contain one of this parameters : access_token, code, error

Then you deploy your own herokuapp?

<!-- gh-comment-id:254646018 --> @phimage commented on GitHub (Oct 18, 2016): Somewhere in your code you must have done " OAuthSwift.handle(url: )" The url is from provider redirection which add some info to your callbackurl Can you check the value of this url. The query of this url must contain one of this parameters : access_token, code, error Then you deploy your own herokuapp?
Author
Owner

@phimage commented on GitHub (Oct 18, 2016):

see #258 and https://github.com/OAuthSwift/OAuthSwift/wiki/Instagram
Did you follow this intruction?

  • Disable implicit OAuth
  • Use webview delegate to call " OAuthSwift.handle(url: )", because info is not un query, but fragment and information mentionned in my previous post will be lost
<!-- gh-comment-id:254646801 --> @phimage commented on GitHub (Oct 18, 2016): see #258 and https://github.com/OAuthSwift/OAuthSwift/wiki/Instagram Did you follow this intruction? - Disable implicit OAuth - Use webview delegate to call " OAuthSwift.handle(url: )", because info is not un query, but fragment and information mentionned in my previous post will be lost
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/OAuthSwift#175
No description provided.