Can´t Login with Twitter - swift

Im trying to Login with Twitter with Firebase in my app i set up everyting but i get this error in console:
Error Domain=TWTRNetworkingErrorDomain Code=-1011 "Request failed:
forbidden (403)" UserInfo={NSLocalizedFailureReason=Twitter API error
: Callback URL not approved for this client application.
Approved callback URLs can be adjusted in your application
settings (code (null)), TWTRNetworkingStatusCode=403,
NSErrorFailingURLKey=https://api.twitter.com/oauth/request_token,
NSLocalizedDescription=Request failed: forbidden (403)
I have set the Callback URL in my twitter settings but i get still that error
That´s my code:
let twitterLoginBtn = TWTRLogInButton { (session, error) in
if let error = error {
debugPrint("Couldn´t LogIn with Twitter: ", error)
return
}
if let session = session {
let credentials = TwitterAuthProvider.credential(withToken: session.authToken, secret: session.authTokenSecret)
self.firebaseLogin(credentials)
print("signed in as \(session.userName)")
} else {
print("error: \(error!.localizedDescription)")
return
}
}
twitterLoginBtn.center.x = twitterLoginView.center.x
twitterLoginView.addSubview(twitterLoginBtn)
heres twitter settings:

To use the SignIn with Twitter service, you have to add the Firebase (like my-app-12345.firebaseapp.com/__/auth/handler) callback URL you're using to a whitelist in your Twitter App Dashboard!
More information here in the Twitter API documentation ;)

Related

Retrieve list of videos from folder in Vimeo Swift 5

I want to query a page of videos from a folder I have hosted on Vimeo. However when doing so, I receive:
Error Domain=com.alamofire.error.serialization.response Code=1011 "Request failed: not found (404)" UserInfo={NSLocalizedDescription=Request failed: not found (404), NSErrorFailingURLKey=https://api.vimeo.com/users/{user-id}/projects/{project-id}/videos, com.alamofire.serialization.response.error.data={length = 51, bytes = 0x7b226572 726f7222 3a225468 65207265 ... 666f756e 642e227d }, ...
I have attempted using different endpoints of the forms: /users/{user-id}/folders/{folder-id}/videos, /users/{user-id}/projects/{project-id}, and /users/{user-id}/folders/{folder-id}, all giving back the same error. I'm currently creating the client and requesting the videos this way:
appConfiguration = AppConfiguration(clientIdentifier: "{id}",
clientSecret: "{secret}", scopes: [.Public, .Private], keychainService: "")
sessionManager = VimeoSesssionManager.defaultSessionManager(baseUrl: VimeoBaseURL,
accessToken: "{access_token}", apiVersion: "3.4")
client = VimeoClient(appConfiguration: appConfiguration, sessionManager: sessionManager)
...
var request: Request? = Request<[VIMVideo]>(path: path)
_ = client.request(request) { result in
switch result {
case .success(let response):
...
case .failure(let error):
print("Error retrieving videos: \(error)")
}
}
However, I have also tried authenticating before hand using the AuthenticationController as specified in the VimeoNetworking GitHub. When testing with the folder id's and the user id on Vimeo's API Reference webpage, everything works fine and I'm able to receive the page of videos just fine.
So I just want to know what I need to do differently to retrieve the page of videos as I was able to do in the Vimeo API Reference website.
The reason the 404 error was being returned was because the Access Token I had created for the application only had the "public" modifier, but when I created a token with the public, private, and video_files, modifiers it worked as expected!

Firebase new user: Identity Toolkit API error

I'm using Firebase auth with swift 4.
I create a new user like this
Auth.auth().createUser(withEmail: emailTextField.text!, password: "abc123!") { (authResult, error) in
// [START_EXCLUDE]
guard let email = authResult?.user.email, error == nil else {
print(error!)
print("NO!!!!!!")
return
}
print("\(email) created")
// [END_EXCLUDE]
guard let user = authResult?.user else { return }
}
But I get this error:
domain = usageLimits;
extendedHelp = "https://console.developers.google.com";
message = "Identity Toolkit API has not been used in project *** before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/identitytoolkit.googleapis.com/overview?project=**** then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.";
reason = accessNotConfigured;
I have enabled identity toolkit API through this link, and it still doesn't work.
I have enabled email and password sign in providers in firebase console.
I deleted firebase project and remade it, and redownloaded the googleservice.plist.
It still doesn't work. I've been hours on it!
Thanks so much,
I have enabled identity toolkit API through this link, and it still doesn't work.
I went back to there, disabled the API, then re-enabled it, and it worked.

swift facebook education and occupation

Designing iOS app and the user is logging into the app using their facebook login. I need to get the user's occupation and education from the facebook profile. I have been told I need initial approval from facebook itself, is this the case?
Any pointers on how I can get the user's occupation and education will be greatly appreciated.
Thanks,
Bruce
This can be done fairly easily.
First You need to register your app on
https://developers.facebook.com
This will create an AppID that you can use for your App.
Parse and Firebase provides Facebook login that can be integrated with your app
For Example if you are using Parse server as your backend Server.
You need to declare a permissions array for this
let permissions = [ "email","user_birthday", "public_profile", "user_friends"]
#IBAction func FacebookLogin(_ sender: Any) {
//var permissions = [ "public_profile" ]
PFFacebookUtils.logInInBackground(withReadPermissions: permissions) { (user, error) in if let user = user {
if user.isNew {
print("User signed up and logged in through Facebook!")
self.displayAlert(title: "Sign up and Login Succesful", message: "Login Successful")
} else {
print("User logged in through Facebook!")
self.displayAlert(title: "Login Succesful", message: "Login Successful")
}
} else {
print("Uh oh. The user cancelled the Facebook login.")
}
}
}
Similar implementations exist for Firebase as well. Probably well documented than Parse server which is open source
Here is a complete list of what you can request from your users
Image Reference https://developers.facebook.com/docs/facebook-login/permissions/

Spotify FB Login with preview api

Anyone knows how the facebook login works with the new preview spotify apps api?
I tried something like this...
require(['$api/facebook'], function(facebook) {
facebook.session.showConnectui();
}
but nothing got me to the result I got with the old api. I also tried to use plain FB js sdk, but the problem is it needs some "url" to allow connections...wich I can't really give out of the spotify app?
Any ideas?
The auth module was not present at first, but now it is part of the Spotify Apps API. You can read more about it on its documentation page. It looks like this:
require(['$api/auth#Auth'], function(Auth) {
var appId = '<your_app_id>',
permissions = ['user_about_me'];
var auth = new Auth();
auth.authenticateWithFacebook(appId, permissions)
.done(function(params) {
if (params.accessToken) {
console.log('Your access token: ' + params.accessToken);
} else {
console.log('No access token returned');
}
}).fail(function(req, error) {
console.error('The Auth request failed with error: ' + error);
});
}
});
In addition, there is a working example in the Tutorial App on GitHub.

deauthorize the user from facebook app

I am getting
A network error occurred while trying to communicate
with Facebook: Facebook POST failed (HTTP status code 400)
when I
try to deauthorize the user from an app.
I am using restfb1.5.1. I
set the access token and other things correctly. This is how I call .
DefaultFacebookClient facebookClient = new
DefaultFacebookClient(access_token);
boolean result = false;
try {
result = facebookClient.deleteObject(userId);
} catch (com.restfb.FacebookException e) {
e.printStackTrace();
}
Due to facebook, if I don't specify the permission,it will
deauthorizes the app.
Anything that I miss?
Thanks ahead.
Use restfb1.6.6 and Check!!
Best wishes..