Google Sheets API with React Native - react-native

New to react-native. Trying to do simple crud operations on a google spreadsheet located in google drive. I've successfully implemented the packages for react-native-google-signin and react-native-google-drive-api-wrapper and can see my spreadsheets. Next step is finding a react-native package that implements google sheets API v4. I've tried Iwark's/react-native-spreadsheet for react/node.js but it produces errors when trying to build in a react-native environment. Any direction would be appreciated.

I am hoping can do this using googleapis and google-auth-library two libraries;
Then initialise the apis by doing
var authClient = new googleAuth();
var auth = new authClient.OAuth2();
auth.credentials = {
access_token: accessToken
};
this.service = google.sheets({version: 'v4', auth: auth});
Then use the this.service
If this doesn't make much sense, wait for few hours or tomorrow, I will help you with a working copy. :)
EDIT:
This is what I think you should do,"
If you have your spreadsheet public, follow this
If your spreadsheet is private
a) You need to make the user login (use firebase google login), then get the access_token and do a get with access_token in https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId} or post request etc.
b) Make a post request in your node server where you handle all of these
Note: I might help you with a working example this weekend.

install
npm install tabletop
import
import Tabletop from 'tabletop';
use
Tabletop.init({
key: url,
callback: googleData => {
console.log(googleData);
},
simpleSheet: true
})
Publishing your Google Sheet
url = File->Publish to the web then click Start publishing

Related

Firebase Magic Link not complete in Android App

I have a React Native Project using Expo Managed Workflow.
The App is built as a expo-dev-client.
I use Firebase Native SDK to authenticate via sendSignInLinkToEmail()
I managed to request the magic link for login. It arrives and when I click it on my android device, the App comes to focus and I am even able to listen to the dynamic link when it comes in.
Problem is it does not validate with isSignInWithEmailLink() because the link I get is only the continueURL parameter of the original link in the Email.
I really don't know where the link is being cut off but I need the complete link from the Email to use signInWithEmailLink() which obviously doesn't work.
When I manually insert the link from the email into signInWithEmailLink() everything works as expected.
I really hope someone has experienced this issue and can help me out!
My Bad. Apparently I was using a Dynamic Link from firebase as I did not have action codes set correct as in:
const actionCodeSettings = {
// URL you want to redirect back to. The domain (www.example.com) for this
// URL must be in the authorized domains list in the Firebase Console.
url: 'https://www.example.com/finishSignUp?cartId=1234',
// This must be true.
handleCodeInApp: true,
iOS: {
bundleId: 'com.example.ios'
},
android: {
packageName: 'com.example.android',
installApp: true,
minimumVersion: '12'
},
dynamicLinkDomain: 'example.page.link'
};

Firebase functions auth.generateEmailVerificationLink() generating link with wrong apiKey

I have a Firebase functions project with dev and prod versions. There I'm using auth.generateEmailVerificationLink() to send email verification for a newly created user. Everything works well except in prod environment (testing locally or hosted) the apiKey in the link generated by auth.generateEmailVerificationLink() is not same as Firebase's default apiKey. And clicking that link I get the page with error code:
Try verifying your email again
Your request to verify your email has expired or the link has already been used
Note that when I get the link with the wrong apiKey, if I change it to the right apiKey. the verification works. So it seems the whole problem is related to the wrong apiKey in generated email verification link.
Also to note that the wrong apiKey is not random key but used in project front end for Google Maps apis.
The code itself is simple. (I'm leaving out code which creates user etc as those parts all work perfectly)
-Initializing Admin SDK:
import { initializeApp } from 'firebase-admin/app';
import { getAuth } from 'firebase-admin/auth';
initializeApp();
const auth = getAuth();
export { auth };
-Generating email verification email
const sendEmail = async () => {
const actionCodeSettings = {
// This url is working correctly, it is the same as in Firebase console
// and when changing the wrong apiKey to correct redirecting works correctly
url: process.env.DOMAIN as string,
};
await auth
.generateEmailVerificationLink(email, actionCodeSettings) // email is the email of newly created user
.then((link) => {
// generate email message with link
// generate mailOptions
// use transporter to send email
});
};
Thank you for any help
EDIT
I tested deleting that "wrong" apiKey from GCP credentials page and replaced it with another. Then running the function locally everything worked normally but the "wrong" is still in the verification email link even tho it doesn't exist anymore.
Firebase strongly recommends that if Admin SDK is used in Cloud Functions, among others, initializing the app should be done without parameters.
https://firebase.google.com/docs/admin/setup#initialize-without-parameters
For me it seems something is for some reason pulling that "wrong" and now even deleted apiKey from somewhere to usage.
I solved this by noticing that, unlike in dev project, Web Api Key (Project Settings>General) is different than Web App's firebaseConfig apiKey.
So I added correct permission to this Web Api Key (Identity Toolkit API is required for email verification email) found in GCP credentials and now the cloud function sends email verification emails with correct and working apiKey.

Is there a way to implement CASAuthentication in a Nestjs app?

I want to dev a backend with NestJS on one of my company project.
I've to check if the user is logged through the CAS (Central Authentication Service).
I wanted to use "express-cas-authentication" npm module, but I can't find out how to implement it in the main.ts file from NestJS.
Here's the npmjs doc page : https://www.npmjs.com/package/express-cas-authentication
Actually, the following lines are annoying me :
app.get( '/app', cas.bounce, function ( req, res ) {
res.send( '<html><body>Hello!</body></html>' );
});
It's not something that works on NestJS as I can see, if someone has a clue it'd be a great help!
Good evening Ladies and Sirs!

Promise rejected and unable to getCollections or getItems within VUE and Directus

Newbie to the world of vueJS and Directus. Learning my way through things by going through the online documentation. Still looking for a decent tutorial showing step by step instructions on how to access a remote install of Directus and use its data in a vueJS app.
My setup is as follows:
vueJS app being developed on my local machine within VS Code Directus
setup and running on a remote server
Within my home.js component I seem to be able to access Directus with the following and no errors in my browser console:
import DirectusSDK from "#directus/sdk-js";
const client = new DirectusSDK();
client.login({
url: "https://mydomain.studio/directus/public/",
project: "events",
email: "email#emailaddress.com.au",
password: "mypassword",
storage: window.localStorage
});
When I attempt to output a listing of the collections with the below I get a rejected Promise and 401 unauthorized.
console.log(client.getCollections());
Hoping that once I get an understanding of why the above does not work and find a solution I will be able to access the data in my Directus seup and use it within my HTML.
All help greatly appreciated. Many thanks in advance.
If there is a newbie step-by-step tutorial explaining how to do the above I would be very glad to go over it.
Many thanks in advance
Disclaimer: I have no idea what Directus is. But something like this should technically work according to their docs:
import DirectusSDK from "#directus/sdk-js";
const client = new DirectusSDK({
url: "https://mydomain.studio/directus/public/",
project: "events",
storage: window.localStorage
});
client.login({
email: "email#emailaddress.com.au",
password: "mypassword",
}).then(response => {
console.log(client.getCollections());
});

Tweeting from within meteor application

I am trying to build an app with Meteor that involves the user signing in with twitter, facebook, or google+, and then posting to those accounts from within the application.
First I'm trying to get twitter to work. I have my twitter sign in working, with the permission to tweet on their behalf working, but how to I actually send a tweet?
I think I need this: https://dev.twitter.com/docs/api/1.1/post/statuses/update but I can't figure out how the authentication works with Meteor.
Are there any examples that can help me here? Or tutorials?
You need an API to help you a bit unless you want to do it manually using REST with Meteor.http. I'd recommend you get meteorite: https://github.com/oortcloud/meteorite
Its installed like a node module via npm install -g meteorite
Meteorite is a wrapper for meteor that lets you use the community packages over at http://atmosphere.meteor.com
The twitter package you could use is twitter-api installed via mrt add twitter-api : https://github.com/Sewdn/meteor-twitter-api
Once added using the server api you can add a tweet via:
Server JS
var twitter = new Twitter();
Meteor.methods({
postTweet: function (text) {
if(Meteor.user())
twitter.postTweet(text),
return true;
}
});
Client JS
//Use this in your click handler where you want to post a tweet:
Meteor.call("postTweet", "This is Twweeeeeetttt!", function(err,result) {
if(!err) {
alert("Tweet posted");
}
});
The api takes care of the user's oauth tokens so you don't have to worry too much