Callback url not approved despite being provided Twitter Api
Asked Answered
D

2

3

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?

Diaphaneity answered 28/5, 2018 at 17:21 Comment(2)
I'm also facing this issue today. Did you check this ? developer.twitter.com/en/docs/basics/callback_url.htmlStormi
Update.. issue resolve for me, I just followed the link I gave before.Stormi
M
17

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>
Mirianmirielle answered 14/6, 2018 at 5:31 Comment(2)
Was having an issue similar issue after the policy update of Twitter. Should be accepted as correct answer.Shark
@Zack. Please if the answer solve your question can you accept the answer. ThanksMirianmirielle
D
0

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!

Diaphaneity answered 3/6, 2018 at 23:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.