Callback url not approved despite being provided T

2019-04-01 18:35发布

In the twitter console I have a callback url from firebase linked. Yet when I try to authenticate using twitter I get the error:

"Request failed: forbidden (403)" UserInfo={NSLocalizedFailureReason=Twitter API error : <?xml version="1.0" encoding="UTF-8"?><errors><error code="415">Callback URL not approved for this client application. Approved callback URLs can be adjusted in your application settings</error></errors> (code (null))

Whats going on? I have tried everything , and no one else on the internet seems to have this issue but me?

2条回答
祖国的老花朵
2楼-- · 2019-04-01 19:19

So heres what worked for me. I used the regular old twitter Kit ( for swift and objective c ) given on twitters GitHub here:

https://github.com/twitter/twitter-kit-ios/wiki

This solved my call back url problems ( I was originally using Alamofire )

This is a good example of an error free network call :

 let client = TWTRAPIClient()
    let statusesShowEndpoint = "https://api.twitter.com/1.1/users/show.json"

    var clientError : NSError?

    let request = client.urlRequest(withMethod: "GET", urlString: statusesShowEndpoint, parameters: ["user_id": "\(currentProfileTwitterUid)"], error: &clientError)

    client.sendTwitterRequest(request) { (response, data, connectionError) -> Void in
        if connectionError != nil {
            print("Error: \(String(describing: connectionError))")
        }

        do {
            if let json = try JSONSerialization.jsonObject(with: data!, options: []) as? Any{

            if let dict = json as? [String : Any]{
                //print(json)


            }
            }



        } catch let jsonError as NSError {
            print("json error: \(jsonError.localizedDescription)")
        }
    }

Hope this helps anyone else!

查看更多
何必那么认真
3楼-- · 2019-04-01 19:31

I face same issue we no need to change in code side, we just need to change some setting in developer account of twitter (tested solution)

You need to add the consumer/api key in Callback URL using below format

Ref link : https://developer.twitter.com/en/docs/basics/callback_url.html

twitterkit-consumer/api key://

enter image description here

You need to add twitterkit-yourConsumerKey in info.plist

<array>
        <dict>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>twitterkit-your Consumer Key (API Key)</string>
            </array>
        </dict>
    </array>
查看更多
登录 后发表回答