[GH-ISSUE #610] renewToken : URL is not valid #397

Open
opened 2026-03-03 16:48:21 +03:00 by kerem · 2 comments
Owner

Originally created by @fukemy on GitHub (Jul 22, 2020).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/610

Description:

OAuth Provider? (Twitter, Github, ..): My custom Auth

OAuth Version:

Version 2

OS (Please fill the version) :

iOS :

Installation method:

CocoaPods

Library version:

v2.1.0

Xcode version:

other: (11.5 -> but this issue came about in 11.4 already)

Hi, i did get access token normally using

 handle = oauthswift.authorize(
            withCallbackURL: "vedaxLink://",
            scope: "openid+profile+vxlink+email+offline_access", state:"INSTAGRAM", parameters: ["nonce" : OAuthSwiftCredential.generateNonce()]) { result in
                switch result {
                case .success(let (credential, _, parameters)):
                    print(credential.oauthToken)
                // Do your request
                case .failure(let error):
                    print(error.localizedDescription)
                }
        }

but when i tried to renew access token, i got error :
Task <D7D3B09E-EC3C-46EB-9637-2E86378A5D19>.<1> finished with error [-1002] Error Domain=NSURLErrorDomain Code=-1002 "URL không được hỗ trợ" UserInfo={NSUnderlyingError=0x283083de0 {Error Domain=kCFErrorDomainCFNetwork Code=-1002 "(null)"}, NSErrorFailingURLStringKey=vedaxLink://#error=login_required&session_state=mwEqxXcZzUZVFm8J3DsdphWObj1felFDUlJQV-bTh0Y.OauRApvQDgUU6HXwfP0-kw, NSErrorFailingURLKey=vedaxLink://#error=login_required&session_state=mwEqxXcZzUZVFm8J3DsdphWObj1felFDUlJQV-bTh0Y.OauRApvQDgUU6HXwfP0-kw, NSLocalizedDescription=URL không được hỗ trợ}

Here is my renew code:

let newParams = ["request_type" : "si:s", "prompt" : "none", "id_token_hint" : UserDefaults.standard.string(forKey: TOKEN_HINT)!, "nonce" : OAuthSwiftCredential.generateNonce(), "redirect_uri" : "vedaxLink://", "response_type" : "code token id_token", "scope" : "openid profile vxlink email offline_access"]
                    oauthswift.renewAccessToken(withRefreshToken: "", parameters: newParams) { (result) in
                        print(result)
                    }

plz help

Originally created by @fukemy on GitHub (Jul 22, 2020). Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/610 ### Description: ### OAuth Provider? (Twitter, Github, ..): My custom Auth ### OAuth Version: Version 2 ### OS (Please fill the version) : iOS : ### Installation method: CocoaPods ### Library version: v2.1.0 ### Xcode version: other: (11.5 -> but this issue came about in 11.4 already) Hi, i did get access token normally using ``` handle = oauthswift.authorize( withCallbackURL: "vedaxLink://", scope: "openid+profile+vxlink+email+offline_access", state:"INSTAGRAM", parameters: ["nonce" : OAuthSwiftCredential.generateNonce()]) { result in switch result { case .success(let (credential, _, parameters)): print(credential.oauthToken) // Do your request case .failure(let error): print(error.localizedDescription) } } ``` but when i tried to renew access token, i got error : ` Task <D7D3B09E-EC3C-46EB-9637-2E86378A5D19>.<1> finished with error [-1002] Error Domain=NSURLErrorDomain Code=-1002 "URL không được hỗ trợ" UserInfo={NSUnderlyingError=0x283083de0 {Error Domain=kCFErrorDomainCFNetwork Code=-1002 "(null)"}, NSErrorFailingURLStringKey=vedaxLink://#error=login_required&session_state=mwEqxXcZzUZVFm8J3DsdphWObj1felFDUlJQV-bTh0Y.OauRApvQDgUU6HXwfP0-kw, NSErrorFailingURLKey=vedaxLink://#error=login_required&session_state=mwEqxXcZzUZVFm8J3DsdphWObj1felFDUlJQV-bTh0Y.OauRApvQDgUU6HXwfP0-kw, NSLocalizedDescription=URL không được hỗ trợ} ` Here is my renew code: ``` let newParams = ["request_type" : "si:s", "prompt" : "none", "id_token_hint" : UserDefaults.standard.string(forKey: TOKEN_HINT)!, "nonce" : OAuthSwiftCredential.generateNonce(), "redirect_uri" : "vedaxLink://", "response_type" : "code token id_token", "scope" : "openid profile vxlink email offline_access"] oauthswift.renewAccessToken(withRefreshToken: "", parameters: newParams) { (result) in print(result) } ``` plz help
Author
Owner

@fukemy commented on GitHub (Jul 22, 2020):

here is my config:

let oauthswift = OAuth2Swift(
            consumerKey:    "****************************",
            consumerSecret: "secret",
            authorizeUrl:   "https://id.vedax.ai/connect/authorize",
            accessTokenUrl: "https://id.vedax.ai/connect/authorize",
            responseType:   "code token id_token"
        )
<!-- gh-comment-id:662384603 --> @fukemy commented on GitHub (Jul 22, 2020): here is my config: ``` let oauthswift = OAuth2Swift( consumerKey: "****************************", consumerSecret: "secret", authorizeUrl: "https://id.vedax.ai/connect/authorize", accessTokenUrl: "https://id.vedax.ai/connect/authorize", responseType: "code token id_token" ) ````
Author
Owner

@jlynch1 commented on GitHub (Jul 27, 2020):

To workaround this issue I subclassed OAuth2Swift and override renewAccessToken() method to set client.credential.oauthToken = "".

It is the same as OAuthSwift/OAuthSwiftAlamofire#11

<!-- gh-comment-id:664339521 --> @jlynch1 commented on GitHub (Jul 27, 2020): To workaround this issue I subclassed `OAuth2Swift` and override `renewAccessToken()` method to set `client.credential.oauthToken = ""`. It is the same as OAuthSwift/OAuthSwiftAlamofire#11
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#397
No description provided.