[GH-ISSUE #136] Not Working with Dribble API when using With OauthSwift Demo examle #84

Closed
opened 2026-03-03 16:45:32 +03:00 by kerem · 4 comments
Owner

Originally created by @sucharuhasija on GitHub (Nov 3, 2015).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/136

let oauthswift = OAuth2Swift(
consumerKey: Dribbble["consumerKey"]!,
consumerSecret: Dribbble["consumerSecret"]!,
authorizeUrl: "https://dribbble.com/oauth/authorize",
accessTokenUrl: "https://dribbble.com/oauth/token",
responseType: "bearer"
)

    oauthswift.authorizeWithCallbackURL( NSURL(string: "oauth-swift://oauth-callback/dribbble")!, scope: "public+write", state: "SucharuHasija", params: ["client_id":Dribbble["consumerKey"]!], success: {
        credential, response, parameters in
      //  self.showAlertView("Dribbble", message: "oauth_token:\(credential.oauth_token)")
        // Get User
        let parameters =  Dictionary<String, AnyObject>()
        oauthswift.client.get("https://api.dribbble.com/v1/user?access_token=\(credential.oauth_token)", parameters: parameters,
            success: {
                data, response in
                let jsonDict: AnyObject! = try? NSJSONSerialization.JSONObjectWithData(data, options: [])
                print(jsonDict)
            }, failure: {(error:NSError!) -> Void in
                print(error)
        })
        }, failure: {(error:NSError!) -> Void in
            print(error.localizedDescription)
    })
Originally created by @sucharuhasija on GitHub (Nov 3, 2015). Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/136 let oauthswift = OAuth2Swift( consumerKey: Dribbble["consumerKey"]!, consumerSecret: Dribbble["consumerSecret"]!, authorizeUrl: "https://dribbble.com/oauth/authorize", accessTokenUrl: "https://dribbble.com/oauth/token", responseType: "bearer" ) ``` oauthswift.authorizeWithCallbackURL( NSURL(string: "oauth-swift://oauth-callback/dribbble")!, scope: "public+write", state: "SucharuHasija", params: ["client_id":Dribbble["consumerKey"]!], success: { credential, response, parameters in // self.showAlertView("Dribbble", message: "oauth_token:\(credential.oauth_token)") // Get User let parameters = Dictionary<String, AnyObject>() oauthswift.client.get("https://api.dribbble.com/v1/user?access_token=\(credential.oauth_token)", parameters: parameters, success: { data, response in let jsonDict: AnyObject! = try? NSJSONSerialization.JSONObjectWithData(data, options: []) print(jsonDict) }, failure: {(error:NSError!) -> Void in print(error) }) }, failure: {(error:NSError!) -> Void in print(error.localizedDescription) }) ```
kerem closed this issue 2026-03-03 16:45:32 +03:00
Author
Owner

@phimage commented on GitHub (Nov 3, 2015):

Have you an error message printed?

<!-- gh-comment-id:153394008 --> @phimage commented on GitHub (Nov 3, 2015): Have you an error message printed?
Author
Owner

@sucharuhasija commented on GitHub (Nov 4, 2015):

No , it doesn't show me the Webpage to login

<!-- gh-comment-id:153776686 --> @sucharuhasija commented on GitHub (Nov 4, 2015): No , it doesn't show me the Webpage to login
Author
Owner

@phimage commented on GitHub (Nov 4, 2015):

you use the demo or copy the code into new project?

how you want to display this page,

  • using the default method
    • into new project see readme "Setting URL Schemes" to declare the scheme "oauth-swift" , a safari will open and redirect to the application (see in code UIApplication.sharedApplication().openURL(url))
  • using an internal web view? (better)
    • see oauthswift.authorize_url_handler = ... to specify what to do with the url , ie. open your web view and load the url
<!-- gh-comment-id:153796844 --> @phimage commented on GitHub (Nov 4, 2015): you use the demo or copy the code into new project? how you want to display this page, - using the default method - into new project see readme "Setting URL Schemes" to declare the scheme "oauth-swift" , a safari will open and redirect to the application (see in code `UIApplication.sharedApplication().openURL(url)`) - using an internal web view? (better) - see `oauthswift.authorize_url_handler = ...` to specify what to do with the url , ie. open your web view and load the url
Author
Owner

@sucharuhasija commented on GitHub (Nov 4, 2015):

Thanks , The issue is resolved due to the internal web view of the Project
.
But i need your help in another issue.
About Pinterest . I integrated all the things as per the instructions in
the Pinterest Site(Pinterest Authentication
https://developers.pinterest.com/docs/api/authentication/ ) and for
OAuthSwift 2.0.

Here is my code.

    let oauthswift = OAuth2Swift(

        consumerKey: Pinterest["consumerKey"]!,

        consumerSecret: Pinterest["consumerSecret"]!,

        authorizeUrl: "https://api.pinterest.com/oauth/ ",

        accessTokenUrl: "https://api.pinterest.com/v1/oauth/token",

        responseType: "code")

    let param = ["response_type":"code","scope":"read_public","state":

"Pinterest","redirect_uri":"https://oauth-callback/pinterest"]

    oauthswift.authorizeWithCallbackURL( NSURL(string: "

https://oauth-callback/pinterest")!, scope: "read_public", state:
"Pinterst",params:
param,success: {

        credential, response, code in

            let parameters =  Dictionary<String, AnyObject>()

        let url = "https://api.pinterest.com/v1/me/?access_token=\(

credential.oauth_token)"

        oauthswift.client.get(url, parameters: parameters,

            success: {

                data, response in

                let jsonDict: AnyObject! = try? NSJSONSerialization.

JSONObjectWithData(data, options: [])

                print(jsonDict)



             //   let result = jsonDict.valueForKey("user") as!

NSDictionary

            }, failure: {(error:NSError!) -> Void in

                print(error)

        })



        }, failure: {(error:NSError!) -> Void in

        print(error)

        })

On Wed, Nov 4, 2015 at 10:47 PM, Phi Mage notifications@github.com wrote:

you use the demo or copy the code into new project?

how you want to display this page,

  • using the default method
    • into new project see readme "Setting URL Schemes" to declare the
      scheme "oauth-swift" , a safari will open and redirect to the application
      (see in code UIApplication.sharedApplication().openURL(url))
  • using an internal web view?
    • see oauthswift.authorize_url_handler = ... to specify what to do
      with the url , ie. open your web view and load the url


Reply to this email directly or view it on GitHub
https://github.com/dongri/OAuthSwift/issues/136#issuecomment-153796844.

<!-- gh-comment-id:153838463 --> @sucharuhasija commented on GitHub (Nov 4, 2015): Thanks , The issue is resolved due to the internal web view of the Project . But i need your help in another issue. About Pinterest . I integrated all the things as per the instructions in the Pinterest Site(Pinterest Authentication https://developers.pinterest.com/docs/api/authentication/ ) and for OAuthSwift 2.0. Here is my code. ``` let oauthswift = OAuth2Swift( consumerKey: Pinterest["consumerKey"]!, consumerSecret: Pinterest["consumerSecret"]!, authorizeUrl: "https://api.pinterest.com/oauth/ ", accessTokenUrl: "https://api.pinterest.com/v1/oauth/token", responseType: "code") let param = ["response_type":"code","scope":"read_public","state": ``` "Pinterest","redirect_uri":"https://oauth-callback/pinterest"] ``` oauthswift.authorizeWithCallbackURL( NSURL(string: " ``` https://oauth-callback/pinterest")!, scope: "read_public", state: "Pinterst",params: param,success: { ``` credential, response, code in let parameters = Dictionary<String, AnyObject>() let url = "https://api.pinterest.com/v1/me/?access_token=\( ``` credential.oauth_token)" ``` oauthswift.client.get(url, parameters: parameters, success: { data, response in let jsonDict: AnyObject! = try? NSJSONSerialization. ``` JSONObjectWithData(data, options: []) ``` print(jsonDict) // let result = jsonDict.valueForKey("user") as! ``` NSDictionary ``` }, failure: {(error:NSError!) -> Void in print(error) }) }, failure: {(error:NSError!) -> Void in print(error) }) ``` On Wed, Nov 4, 2015 at 10:47 PM, Phi Mage notifications@github.com wrote: > you use the demo or copy the code into new project? > > how you want to display this page, > - using the default method > - into new project see readme "Setting URL Schemes" to declare the > scheme "oauth-swift" , a safari will open and redirect to the application > (see in code UIApplication.sharedApplication().openURL(url)) > - using an internal web view? > - see oauthswift.authorize_url_handler = ... to specify what to do > with the url , ie. open your web view and load the url > > — > Reply to this email directly or view it on GitHub > https://github.com/dongri/OAuthSwift/issues/136#issuecomment-153796844.
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#84
No description provided.