[GH-ISSUE #350] how to acces ouath without authorizeUrl #220

Closed
opened 2026-03-03 16:46:47 +03:00 by kerem · 5 comments
Owner

Originally created by @megifernanda on GitHub (Mar 13, 2017).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/350

Description:

before i tried to get token with this code but i just got oauth_token and work but actually my app wihout authorize, so how to make this code without authorizeUrl

if i make authorizeUrl: "https://accounts.8villages.com/oauth/request-token"
my app is work and get token in url browser
but in layout i get error like this

MethodNotAllowedError

my code :

import UIKit
      import OAuthSwift

    class ViewController: UIViewController {

    var oauthswift: OAuth1Swift?
    
    override func viewDidLoad() {
        super.viewDidLoad()
        doAuthPetani()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    func doAuthPetani() {
        
        print ("hei")
        var is8VillagesInstalled: Bool = {
            let appUrl = URL(string: "8villages://app")
            return UIApplication.shared.canOpenURL(appUrl!)
        }()
        
        self.oauthswift = OAuth1Swift.init(consumerKey: "xxx.", consumerSecret: "xxx.", 
requestTokenUrl: "https://oauth.8villages.com/tokens/request-token", 
authorizeUrl: "8villages://app/?oauth_token_secret=", 
accessTokenUrl: "https://accounts.8villages.com/tokens/access-token")
        
        self.oauthswift?.authorizeURLHandler = OAuthSwiftOpenURLExternally.sharedInstance
        self.oauthswift?.allowMissingOAuthVerifier = true
        
        self.oauthswift?.authorize(
            withCallbackURL: "8villages://app/oauth-callback",
        success: { credentials, response, parameters in
            print("credentials", credentials)
            print("response =", response!)
            print("parameters=", parameters)
        }, failure: { error in
            print("the error is", error.description, error.errorCode)
        });
        
    
    }
    }


       extension ViewController: UIWebViewDelegate {
       func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest,     navigationType: UIWebViewNavigationType) -> Bool {
        
        let urlString = request.url!.absoluteString
        let redirectUri = "YOUR_URL"
        if let _ =  urlString.range(of: "\(redirectUri)?code=") {
            OAuthSwift.handle(url: request.url!)
         //self.dismissWebViewController()
         }
         return true
     }
     }

OAuth Provider (Twitter, Github, ..):

https://accounts.8villages.com/authentication

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: (i dont know.)

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 @megifernanda on GitHub (Mar 13, 2017). Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/350 ### Description: before i tried to get token with this code but i just got oauth_token and work but actually my app wihout authorize, so how to make this code without authorizeUrl if i make authorizeUrl: "https://accounts.8villages.com/oauth/request-token" my app is work and get token in url browser but in layout i get error like this **MethodNotAllowedError** my code : ```swift import UIKit import OAuthSwift class ViewController: UIViewController { var oauthswift: OAuth1Swift? override func viewDidLoad() { super.viewDidLoad() doAuthPetani() } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } func doAuthPetani() { print ("hei") var is8VillagesInstalled: Bool = { let appUrl = URL(string: "8villages://app") return UIApplication.shared.canOpenURL(appUrl!) }() self.oauthswift = OAuth1Swift.init(consumerKey: "xxx.", consumerSecret: "xxx.", requestTokenUrl: "https://oauth.8villages.com/tokens/request-token", authorizeUrl: "8villages://app/?oauth_token_secret=", accessTokenUrl: "https://accounts.8villages.com/tokens/access-token") self.oauthswift?.authorizeURLHandler = OAuthSwiftOpenURLExternally.sharedInstance self.oauthswift?.allowMissingOAuthVerifier = true self.oauthswift?.authorize( withCallbackURL: "8villages://app/oauth-callback", success: { credentials, response, parameters in print("credentials", credentials) print("response =", response!) print("parameters=", parameters) }, failure: { error in print("the error is", error.description, error.errorCode) }); } } extension ViewController: UIWebViewDelegate { func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool { let urlString = request.url!.absoluteString let redirectUri = "YOUR_URL" if let _ = urlString.range(of: "\(redirectUri)?code=") { OAuthSwift.handle(url: request.url!) //self.dismissWebViewController() } return true } } ``` ### OAuth Provider (Twitter, Github, ..): https://accounts.8villages.com/authentication ### OAuth Version: - [x] Version 1 - [ ] Version 2 ### OS (Please fill the version) : - [x] iOS : - [ ] OSX : - [ ] TVOS : - [ ] WatchOS : ### Installation method: - [x] Carthage - [x] CocoaPods - [ ] Manually ### Library version: - [ ] head - [ ] v1.0.0 - [ ] v0.6 - [x] other: (i dont know.) ### 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 closed this issue 2026-03-03 16:46:48 +03:00
Author
Owner

@phimage commented on GitHub (Mar 13, 2017):

please provide a link to the provider api documentation

<!-- gh-comment-id:286093137 --> @phimage commented on GitHub (Mar 13, 2017): please provide a link to the provider api documentation
Author
Owner

@megifernanda commented on GitHub (Mar 14, 2017):

this https://accounts.8villages.com/authentication

<!-- gh-comment-id:286300967 --> @megifernanda commented on GitHub (Mar 14, 2017): this https://accounts.8villages.com/authentication
Author
Owner

@phimage commented on GitHub (Mar 14, 2017):

Maybe I must be logged somewhere because i receive
{"code":"MethodNotAllowedError","message":"GET is not allowed"}
Or this not a Doc link

<!-- gh-comment-id:286324659 --> @phimage commented on GitHub (Mar 14, 2017): Maybe I must be logged somewhere because i receive {"code":"MethodNotAllowedError","message":"GET is not allowed"} Or this not a Doc link
Author
Owner

@megifernanda commented on GitHub (Mar 14, 2017):

yaaa because that i ask here how to make without authorize. because it skip auhtorize sir

<!-- gh-comment-id:286338464 --> @megifernanda commented on GitHub (Mar 14, 2017): yaaa because that i ask here how to make without authorize. because it skip auhtorize sir
Author
Owner

@phimage commented on GitHub (Mar 14, 2017):

So you DO NOT respond to my request, to provide a link to 8villages documentation

did you try https://oauth.8villages.com/tokens/authorize
or
are you sure it's oauth version 1 ?

I can't help you more than that

<!-- gh-comment-id:286346930 --> @phimage commented on GitHub (Mar 14, 2017): So you DO NOT respond to my request, to provide a link to 8villages documentation did you try https://oauth.8villages.com/tokens/authorize or are you sure it's oauth version 1 ? I can't help you more than that
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#220
No description provided.