Google Oauth flow in Meteor - meteor

Within a Meteor app, can anyone guide me to how to allow users to simply Oauth Google?
There's the accounts-google package, but I don't want users to be able to login with it, just oauth and store credentials.
The docs mention "If you just want to authenticate to an Oauth service like Twitter, Facebook, or Google without using Accounts – that is, if you don't want to log the user in, you just want an OAuth token – you can use the underlying service packages such as twitter, facebook, and google directly.", but there are no docs whatsoever for the google package.
Any guidance would be much appreciated.

The Oauth's package is intended to do just this. If you want to use it to get people's credentials
There are two options:
1) Modify the source of the google and accounts-google packages to remove the parts that log you in. There are no docs for this, i'm afraid, the best to understand it are the inline comments.
2) Use another atmosphere package to merge accounts-google with an existing login. So they're already logged in but can use Meteor.logInWithGoogle() to login with google and this is merged with their existing account. This way they don't have to log in with Google but you get to store the OAuth token. For this you can use the bozhao:link-accounts package, or the mikael:accounts-merge package:
// ON THE CLIENT:
Meteor.signInWithGoogle ({}, function (error, mergedUserId) {
// mergedUsers is set if a merge occured
if (mergedUserId) {
console.log(mergedUserId, 'merged with', Meteor.userId());
}
});
Then you would find the google OAuth token data in services.google on your existing Meteor.user() document.

It's fairly straight forward to handle the Google OAuth manually. Check my answer on this (similar) SO question
Getting OAuth tokens without user registration

Related

How do I add users on workspace through API in Clockify

I understand the reason for protecting endpoints with reCapture, but what is the reason to declare a call for adding new users https://clockify.github.io/clockify_api_docs/#operation--workspaces--workspaceId--users-post if the only response is {'message': 'reCaptcha was not successfully validated.', 'code': 501}?
How is it planned in Clockify to add users to a workspace through API?
I have the same issue. Note however that that is the unstable api, and the add user function is not yet in the stable api https://clockify.me/developers-api

Log in restriction using firebase auth

I've created a website using firebase authentication system. The website is intended for a specifik group of people which means i want to restrict sign up/log in for this group.
I've been looking around for a solution but haven't been able to find a good one. I got a tip about creating a "whitelist" for the allowed users and changing the security rules so that .read is true for these people. But would this restrict login?
So basically I'm wondering if anyone else has bumped into this problem? Or if anyone has a good solution?
What you can do is to set up FireBase Auth using the Email/Password signin provider.
Then, create a backend page/tool to pre-register the users and send them a verification email.
Details found in FireBase doc: https://firebase.google.com/docs/auth/users

How do you access Facebook scope data with Firebase Auth

I'm trying to access data requested from Facebook. Here is my code:
var auth_provider_facebook = new firebase.auth.FacebookAuthProvider();
/// BEGIN: configure the facebook authorization provider.
auth_provider_facebook.addScope('user_birthday');
auth_provider_facebook.addScope('user_about_me');
auth_provider_facebook.addScope('user_work_history');
auth_provider_facebook.addScope('user_education_history');
// auth_provider_facebook.addScope('user_birthday,user_about_me,user_work_history,user_education_history');
/// END: configure the facebook authorization provider.
I've tried one-lining it and multi-lining it, but I am still having trouble getting the data. The documentation found here has absolutely no information on retrieving data from the scope. The documentation provided here mentions a facebook variable as part of the result, but it's always undefined. There's more documentation here that brings up a thirdPartyUserData property which is also always undefined.
How do I go about obtaining this data?
When you authenticate, onAuthStateChange will give you a token. This is mine with multiple account linked.
Can you find it? Are you using Firebase v3?

Meteor: Verifying user's twitter account, without logging in

Meteor can let a user authenticate that she controls a Twitter account without logging in:
Standalone OAuth client use
If you just want to authenticate to an Oauth service like Twitter,
Facebook, or Google without using Accounts – that is, if you don't
want to log the user in, you just want an OAuth token – you can use
the underlying service packages such as twitter, facebook, and google
directly.
But, I haven't been able to find any information on how to do this in the documentations. I tried reading the packages for twitter and oauth, but it seems you have to change the code to make a call to Twitter without creating an account.
There are some solutions to a similar problem, like using Accounts.onCreateUser(function(options, user), where you can hinder external services from making an account on your app. But, I want to let some twitter accounts create a normal account, and others to not be able to create one at all.
I tried adding a custom object to Twitter.requestCredential(options, callback) and to Meteor.loginWithTwitter(options, callback), but neither worked.
Does anyone know how to solve this problem of letting users verify their twitter accounts without creating an account (and without completely stopping people from creating an account with twitter)?

Accessing Google analytics api using api key

I'm trying to implement Google analytics API using API key to make it available without authorization. But i can get examples using CLIENT ID in google developer console itself. Can anyone help me with an example using api key?
It is not possible to access Google Analytics API with the API key. You must use Open Authentication.
If you are trying to access your own data you can use a service account. Create new credentials choose Service Account.
You can then take the service account email address:
1046123799103-nk421gjc2v8mlr2qnmmqaak04ntb1dbp#developer.gserviceaccount.com
Add it as a user at the ACCOUNT level it is very important that it be at the ACCOUNT level it wont work other wise. Your application with then be able to access your Google Analytics data with out a log in.
Without knowing what language you are working with I cant give you any examples.
Update:
If as you say you are planning on doing this with JavaScript then you will have to go with Oauth2 and request access. There is no way to use a Service account with JavaScript.
There for I strongly recommend that you find a server sided programing language to do this in. Even if it did work with JavaScript you would end up running out of quota on the API before to long.
Google Analytics' EmbedAPI will allow you to display your Google Analytics via javascript, and users will be able to log in on page.
You will still need to get your clientAPI, but then users will be able to login independently.
The javascript code is described in the dev guide and a sample is below:
<script>
gapi.analytics.ready(function() {
// Step 3: Authorize the user.
var CLIENT_ID = 'Insert your client ID here';
gapi.analytics.auth.authorize({
container: 'auth-button',
clientid: CLIENT_ID,
});
</script>
The API limit should be no problem, its 50,000 calls per day.

Resources