Firebase Login signIn Linkedin [duplicate] - ios

I'm currently building an app and I would like people to be able to sign up with their LinkedIn account.
I'm using Firebase for the back-end and LinkedIn isn't currently supported by the FirebaseAuth framework.
I know Firebase allows Custom Auth System but even after reading the doc about this, I still struggle to understand how I can plug LinkedIn there and what the so-called authentification server is.
Has someone managed to make this work?
Thanks in advance for your inputs.

Firebase Authentication supports only four federated Identity Providers out of the box: Google, Facebook, Twitter and GitHub.
For every other provider you have to use custom tokens (you will need an external Webservice).
You can read more here for a full example (the link is for Instagram but it will also work for LinkedIn as they say).

See this example in official Firebase repo: Use LinkedIn Sign In with Firebase
In this sample we use OAuth 2.0 based authentication to get LinkedIn
user information then create a Firebase Custom Token (using the
LinkedIn user ID).

Looks like the post is few years old, so not sure if you have found the solution, but for the benefit of everyone. in the current version of firebase, this is how I was able to use LinkedIn.
export function signUpWithLinkedIn() {
return auth
.setPersistence(firebase.auth.Auth.Persistence.SESSION)
.then(()=>{
const provider = new firebase.auth.OAuthProvider('linkedin.com');
provider.addScope('r_emailaddress');
provider.addScope('r_liteprofile');
auth
.signInWithPopup(provider)
.then(result=>{
console.group('LinkedIn');
console.log(result);
console.groupEnd();
return result;
})
.catch(error=>{
console.group('LinkedIn - Error');
console.log(error)
console.groupEnd();
throw error;
});
});
}

Related

Custom scheme URIs are not allowed for 'Web' client type - Google with Firebase

I am trying to implement google sign in using firebase in to my iOS app. I follow this tutorial.
https://firebase.google.com/docs/auth/ios/google-signin
I have setup the iOS app in firebase and use the google clientID and reversedClientID from the dowloaded GoogleService-Info.plist.
FYI: I have a custom sign-in button instead of the google sign in button. Anyway when i click the sign in button, google following error display in a webview.
I know my problem is the same as which described in this question.
Google 400 Error: invalid request Custom scheme URIs are not allowed for 'Web' client type
But, in my case, I have created the app in Firebase still I get the error. Any idea please...
The first step is to check if you have already the OAuth 2.0 ID for iOS. To do this please open the Credentials page in the API Console. I hope you will find iOS client for your application under OAuth 2.0 client IDs section. If not, please follow this Guide
The second step is to replace the Web Client ID with in iOS Client ID from OAuth 2.0 client IDs section. To do this, you should open the GoogleService-Info.plist and modify following keys: CLIENT_ID with [value].apps.googleusercontent.com and REVERSED_CLIENT_ID with com.googleusercontent.apps.[value].
if you're using flutterfire ui package you need to change the client id parameter in your GoogleProviderConfiguration class with the iOS client id,
you can copy it from here Credential page
example:
providerConfigs: [
GoogleProviderConfiguration(
clientId: "your copied key here"),
]
re-build you're app and you should be good to go
I've just faced this same issue using flutterfire_ui on Flutter.
The error appears to be from a couple of things. As Valeriy points out you need the ios client ID. But I still got the error if I used the scopes
openid
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/userinfo.profile",
Instead change these to
openid
email
profile
Strangely the opposite is true for Android, where the WebID and the first of the scopes should be used.
It also pays to be aware of the OAuth Content Screen..
In google cloud go to APIs & Services > OAuth consent screen > Edit.
You can add scopes here and fix any missing required fields that Firebase might not be filling out (I had 1). I believe this takes a while to propagate after a change, so give it an hour.

Has someone managed to implement a LinkedIn login with Firebase on iOS?

I'm currently building an app and I would like people to be able to sign up with their LinkedIn account.
I'm using Firebase for the back-end and LinkedIn isn't currently supported by the FirebaseAuth framework.
I know Firebase allows Custom Auth System but even after reading the doc about this, I still struggle to understand how I can plug LinkedIn there and what the so-called authentification server is.
Has someone managed to make this work?
Thanks in advance for your inputs.
Firebase Authentication supports only four federated Identity Providers out of the box: Google, Facebook, Twitter and GitHub.
For every other provider you have to use custom tokens (you will need an external Webservice).
You can read more here for a full example (the link is for Instagram but it will also work for LinkedIn as they say).
See this example in official Firebase repo: Use LinkedIn Sign In with Firebase
In this sample we use OAuth 2.0 based authentication to get LinkedIn
user information then create a Firebase Custom Token (using the
LinkedIn user ID).
Looks like the post is few years old, so not sure if you have found the solution, but for the benefit of everyone. in the current version of firebase, this is how I was able to use LinkedIn.
export function signUpWithLinkedIn() {
return auth
.setPersistence(firebase.auth.Auth.Persistence.SESSION)
.then(()=>{
const provider = new firebase.auth.OAuthProvider('linkedin.com');
provider.addScope('r_emailaddress');
provider.addScope('r_liteprofile');
auth
.signInWithPopup(provider)
.then(result=>{
console.group('LinkedIn');
console.log(result);
console.groupEnd();
return result;
})
.catch(error=>{
console.group('LinkedIn - Error');
console.log(error)
console.groupEnd();
throw error;
});
});
}

How to configure scope of information I gather from Google OAuth in MeteorJS package?

Tried searching google and StackOverflow but with no luck, perhaps your knowledge of Google-OAuth can help...
I installed the base google-oauth package via meteor.
meteor add accounts-ui
meteor add accounts-google
Then I tested it out and saw that it requests the user to permit access to 2 main groups on information, the first being the user's email and the second being "basic information" about the users account, e.g. Name, Gender, Public Profile URL etc etc.
I only want the email and no other information. I tried to look for where the URI request is built in my meteor app, someurlprobablygoogle.com/scope=email&profile or whatever, but I can't seem to find it.
To configure Google OAuth in Meteor you need to meteor add service-configuration and meteor add accounts-google.
You should be able to modify the requestPermissions setting when calling your login method like so:
Meteor.loginWithGoogle({
requestPermissions: ['email']
}, function (err) {
if (err)
Session.set('errorMessage', err.reason || 'Unknown error');
});
Shooooots

Twitter API 1.1 Oauth w/ Meteor

I'm pretty new to Meteor and a total beginner with the Twitter API. I am creating a simple application in Meteor for demonstration purposes only. I need to be able to search Twitter for a specific hashtag. I just need to be able to get the tweets using that hashtag and display them in a list. Super simple.
I've registered my app, received keys and such. I just need to see an example of the code flow from starting before Oauth to receiving the results of the Twitter search.
I will be running this app locally and just need to be able to send a GET request and receive a RESTful response.
I have seen documentation about how jQuery isn't supported due to security risks. Since my backend is JS I need to be able to do this with JS.
Can anyone suggest documentation on how I can do this where I can see code examples?
Since the v1.1 of Twitter API (may 2013), it's not possible to search without being authorized using OAuth.
If you want to do it client side in a simple way, you may want to use OAuth.io.
I've just made an example in jsfiddle to make a simple search using Twitter API
The code is quite simple:
//Initialize the SDK with my OAuth.io public key, then display the OAuth authorization form
OAuth.initialize('YOUR-PUBLIC-KEY')
OAuth.popup('twitter', function(err, twitter) {
var search = encodeURIComponent("#oauth.io")
twitter.get('/1.1/search/tweets.json?q=' + search)
.done(function(data) {
console.log(data); //your search results are in data
})
})
Good question. You are correct, the Twitter 1.1 API requires oAuth tokens even for simple GET requests like the one you need. Yeah, requesting an oAuth key and secret from the twitter dev site can seem like overkill for a locally running project, but it's required for every one of their API endpoints.
Once you have the oAuth consumer key and secret, you are all set to make your API calls. Casual googling on the twitter dev site suggests that sending oAuth creds via JQuery is not supported by Twitter for security reasons. You can read more about that here.
I am not sure what you need to do with the Twitter data, so I'm not embedding any code samples for oAuth. In the mean time, check out how oAuth works as you think about how to implement your solution. PHP? Python? Ruby? Perhaps these oAuth code samples from Twitter are a good place to start?
There is a meteorite library intended to get around this exact problem.
https://github.com/subhog/meteor-twit
You can follow the documentation for use:
https://github.com/ttezel/twit
Below is some example code:
if (Meteor.isServer) {
Meteor.methods({
twit_get: function() {
Twit = new TwitMaker({
consumer_key: 'foo',
consumer_secret: 'foo',
access_token: 'foo',
access_token_secret: 'foo'
});
Twit.get(
'search/tweets',
{
q: 'banana since:2013-12-11',
count: 10
},
function(err, reply) {
console.log(reply);
});
}
});
}

Sign in via Twitter (iOS)

I am developing an iOS app and want to implement native sign in via Twitter. I am using an example I found here that includes 2 steps, request token and access token. For the second step I use my twitter ACAccount (account.framework) and my app consumer_key and consumer_secret, and finally obtain an oath_token and oath_token_secret.
The problem is that when I try to fetch data with that token in my app API I get invalid token.
I think a step might be missing here or something. I look at every post related to sign in via Twitter and couldn't solve this...
Thanks everyone
This is the example I based my code
https://github.com/seancook/TWReverseAuthExample
I did almost everything the same, I am using ARC

Resources