[GH-ISSUE #708] Twitter SignIn - SessionStorage Error #457

Open
opened 2026-03-03 16:48:49 +03:00 by kerem · 3 comments
Owner

Originally created by @Dave181295 on GitHub (Jul 29, 2023).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/708

Description:

OAuth Provider? (Twitter, Github, ..): Twitter

OAuth Version:

  • Version 1
  • Version 2

OS (Please fill the version) :

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

Installation method:

  • Carthage
  • CocoaPods
  • Swift Package Manager
  • Manually

Library version:

  • head
  • v2.1.0
  • v2.0.0
  • v1.4.1
  • other: (Please fill in the version you are using.)

Xcode version:

  • 11.4 (Swift 5.2)

  • 11.x (Swift 5.1)

  • 10.x (Swift 5.0)

  • other: (Please fill in the version you are using.) 14

  • objective c

Whenever trying to login , the safari opens inApp and then we got the error:

Unable to process request due to missing initial state. This may happen if browser sessionStorage is inaccessible or accidentally cleared.

Code


 oauthSwift = OAuth1Swift(
            consumerKey:    consumerKey,
            consumerSecret: consumerSecret,
            requestTokenUrl: "https://api.twitter.com/oauth/request_token",
            authorizeUrl:    "https://api.twitter.com/oauth/authorize",
            accessTokenUrl:  "https://api.twitter.com/oauth/access_token"
            
        )
       
        oauthSwift.authorizeURLHandler = SafariURLHandler(viewController: parent, oauthSwift: oauthSwift)
        
view
 .onOpenURL { url  in
                
                if url.host == "oauth" && url.scheme == "twitter" {
                    // Handle Twitter login
                    OAuthSwift.handle(url: url )
                    
                }
Originally created by @Dave181295 on GitHub (Jul 29, 2023). Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/708 ### Description: ### OAuth Provider? (Twitter, Github, ..): Twitter ### OAuth Version: - [x] Version 1 - [ ] Version 2 ### OS (Please fill the version) : - [x] iOS : - [ ] OSX : - [ ] TVOS : - [ ] WatchOS : ### Installation method: - [ ] Carthage - [ ] CocoaPods - [x] Swift Package Manager - [ ] Manually ### Library version: - [ ] head - [ ] v2.1.0 - [ ] v2.0.0 - [ ] v1.4.1 - [x] other: (Please fill in the version you are using.) ### Xcode version: - [ ] 11.4 (Swift 5.2) - [ ] 11.x (Swift 5.1) - [ ] 10.x (Swift 5.0) - [x] other: (Please fill in the version you are using.) 14 - [ ] objective c Whenever trying to login , the safari opens inApp and then we got the error: ``` Unable to process request due to missing initial state. This may happen if browser sessionStorage is inaccessible or accidentally cleared. ``` **Code** ``` oauthSwift = OAuth1Swift( consumerKey: consumerKey, consumerSecret: consumerSecret, requestTokenUrl: "https://api.twitter.com/oauth/request_token", authorizeUrl: "https://api.twitter.com/oauth/authorize", accessTokenUrl: "https://api.twitter.com/oauth/access_token" ) oauthSwift.authorizeURLHandler = SafariURLHandler(viewController: parent, oauthSwift: oauthSwift) ``` ``` view .onOpenURL { url in if url.host == "oauth" && url.scheme == "twitter" { // Handle Twitter login OAuthSwift.handle(url: url ) } ```
Author
Owner

@bharatlal087 commented on GitHub (Nov 7, 2023):

Is there any progress on this issue?

<!-- gh-comment-id:1798216146 --> @bharatlal087 commented on GitHub (Nov 7, 2023): Is there any progress on this issue?
Author
Owner

@phimage commented on GitHub (Nov 7, 2023):

nope, code provided is not enought, not authorize call etc... this could be your callback url that not matching one defined in twitter app declaration
then maybe twitter go to oauth 2, because missing state is somethings that I see more with this protocol version

<!-- gh-comment-id:1798339598 --> @phimage commented on GitHub (Nov 7, 2023): nope, code provided is not enought, not authorize call etc... this could be your callback url that not matching one defined in twitter app declaration then maybe twitter go to oauth 2, because missing state is somethings that I see more with this protocol version
Author
Owner

@Dave181295 commented on GitHub (Nov 11, 2023):

nope, code provided is not enought, not authorize call etc... this could be your callback url that not matching one defined in twitter app declaration
then maybe twitter go to oauth 2, because missing state is somethings that I see more with this protocol version

private let callbackURL = "https://appname.firebaseapp.com/__/auth/handler"

the same callbackUrl is applied in twitter dashboard, tried with our custom domain and still getting the same error.

<!-- gh-comment-id:1806707937 --> @Dave181295 commented on GitHub (Nov 11, 2023): > nope, code provided is not enought, not authorize call etc... this could be your callback url that not matching one defined in twitter app declaration > then maybe twitter go to oauth 2, because missing state is somethings that I see more with this protocol version ``` private let callbackURL = "https://appname.firebaseapp.com/__/auth/handler" ``` the same callbackUrl is applied in twitter dashboard, tried with our custom domain and still getting the same error.
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#457
No description provided.