[GH-ISSUE #61] 401 #42

Closed
opened 2026-03-03 16:45:06 +03:00 by kerem · 3 comments
Owner

Originally created by @amycheong19 on GitHub (May 7, 2015).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/61

I'm using the same link and I tried to access it from POSTMAN and it worked so I tried it in mobile but it ended up return 401 http error. Is there anything i missed out?

screen shot 2015-05-08 at 7 44 14 am

func doOAuthTwitter(){
    let oauthswift = OAuth1Swift(
        consumerKey:    Twitter["consumerKey"]!,
        consumerSecret: Twitter["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.webViewController = WebViewController()
    oauthswift.authorizeWithCallbackURL( NSURL(string: "oauth-swift://oauth-callback/twitter")!, success: {
        credential, response in
        self.showAlertView("Twitter", message: "auth_token:\(credential.oauth_token)\n\noauth_toke_secret:\(credential.oauth_token_secret)")
        var parameters =  Dictionary<String, AnyObject>()
        oauthswift.client.get("https://api.twitter.com/1.1/account/verify_credentials.json?skip_status=true&include_email=true", parameters: parameters,
            success: {
                data, response in
                let jsonDict: AnyObject! = NSJSONSerialization.JSONObjectWithData(data, options: nil, error: nil)
                println(jsonDict)
            }, failure: {(error:NSError!) -> Void in
                println(error)
            })

        }, failure: {(error:NSError!) -> Void in
            println(error.localizedDescription)
        }
    )
}
Originally created by @amycheong19 on GitHub (May 7, 2015). Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/61 I'm using the same link and I tried to access it from POSTMAN and it worked so I tried it in mobile but it ended up return 401 http error. Is there anything i missed out? ![screen shot 2015-05-08 at 7 44 14 am](https://cloud.githubusercontent.com/assets/9781961/7528108/15449b6a-f556-11e4-8d8f-e63cf7040dcb.png) ``` func doOAuthTwitter(){ let oauthswift = OAuth1Swift( consumerKey: Twitter["consumerKey"]!, consumerSecret: Twitter["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.webViewController = WebViewController() oauthswift.authorizeWithCallbackURL( NSURL(string: "oauth-swift://oauth-callback/twitter")!, success: { credential, response in self.showAlertView("Twitter", message: "auth_token:\(credential.oauth_token)\n\noauth_toke_secret:\(credential.oauth_token_secret)") var parameters = Dictionary<String, AnyObject>() oauthswift.client.get("https://api.twitter.com/1.1/account/verify_credentials.json?skip_status=true&include_email=true", parameters: parameters, success: { data, response in let jsonDict: AnyObject! = NSJSONSerialization.JSONObjectWithData(data, options: nil, error: nil) println(jsonDict) }, failure: {(error:NSError!) -> Void in println(error) }) }, failure: {(error:NSError!) -> Void in println(error.localizedDescription) } ) } ```
kerem closed this issue 2026-03-03 16:45:06 +03:00
Author
Owner

@crisogray commented on GitHub (May 31, 2015):

Same here, any solution?

<!-- gh-comment-id:107198962 --> @crisogray commented on GitHub (May 31, 2015): Same here, any solution?
Author
Owner

@ohcrfpv commented on GitHub (Jul 19, 2015):

Make sure your app has the login permission.
You can setting it in https://apps.twitter.com/app/5250618/settings ,5250618 is my app id,use your app id to replace it.
It will be working.

demo

<!-- gh-comment-id:122648234 --> @ohcrfpv commented on GitHub (Jul 19, 2015): Make sure your app has the login permission. You can setting it in `https://apps.twitter.com/app/5250618/settings` ,`5250618` is my app id,use your app id to replace it. It will be working. ![demo](https://cloud.githubusercontent.com/assets/3256161/8765620/0361b37c-2e47-11e5-8d4e-67266677758f.png)
Author
Owner

@phimage commented on GitHub (Aug 7, 2015):

@amycheong19 please close this issue

<!-- gh-comment-id:128832795 --> @phimage commented on GitHub (Aug 7, 2015): @amycheong19 please close this issue
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#42
No description provided.