How to properly call and implement ConnectyCube's External auth via Custom Identity Provider - react-native

I'm trying to implement Custom Identity Provider of ConnectyCube.
The instructions are:
I am now trying to implement the last step:
POST https://api.connectycube.com/login
login=IP_user_token
I try to do the above by the following code:
const login = {
login: token,
};
try {
const {data} = await axios.post(
`https://api.connectycube.com/login`,
login,
);
console.log('data', data);
} catch (err) {
console.log('err while calling api.connectycube.com/login err', err);
}
When I do that though I get the following 403 error:
[Error: Request failed with status code 403]
Am I POSTing incorrectly?
How to fix?

Related

how to access exceptions thrown by Nestjs from frontend?

I am building backend API with Nestjs and I want to access exeptions from frontend
this is a simple example from login endpoint when user enters non-existent email :
const user = await this.userModel.findOne({ email });
if (!user) {
throw new NotFoundException('email does not exist .');
}
now when I send request from my Nextjs application like this :
await axios
.post(`http://127.0.0.1:5000/user/login`, {
email: values.email,
password: values.password,
})
.then((res) => {
console.log(res);
})
.catch((error) => {
console.log("Login catched an error : ", error);
});
I get the NotFoundException as error:
now I want to get the status of this error (404 in this case),is it possible ?
It's an AxiosError, so you should be able to access error.response.status as shown in Axios's documentation

OAuth 2Client: Invalid token signature

I wanted to handle my user auth by google.
async verify(token) {
try {
const ticket = await client.verifyIdToken({
idToken:token,
audience: '245409008225-isc00em81fk0vs423pm4jmgc2hcma5jj.apps.googleusercontent.com',
});
const payload = ticket.getPayload();
return payload
} catch (error) {
console.log(error)
}
this code works fine, only for first time to create user in DB. And i save this token to localstorage and retrieve it every time to validate that user is authentificated. Here is my code:
async isAuth(token) {
if (!token) {
false
}
const userData = tokenService.verify(token);
const tokenFromDb = await tokenService.findToken(token);
if (!userData || !tokenFromDb) {
throw ApiError.UnAuthorizedError();
}
const user = await User.findOne({where: {email: userData.email}});
await tokenService.saveToken(token);
return true;
}
I did google, and i supposed to define jwk key for google auth api? But I can't find real solution. So, hope you guys can help me. I never used before google auth. For now I have this solution by making request to this api https://www.googleapis.com/oauth2/v1/tokeninfo?id_token=token and getting from there my user email

'Unexpected end of JSON input' error while working with Shopify webhooks

I've created an app and try to register for webhooks, and then fetch the list of all webhooks.
I use this code for this (/server/middleware/auth.js):
const webhook = new Webhook({ session: session });
webhook.topic = "products/update";
webhook.address = "https://api.service.co/items/update";
webhook.format = "json";
console.log("registering products/update");
try {
await webhook.save({
update: true,
});
} catch (error) {
console.log(error);
}
const webhookSecond = new Webhook({ session: session });
webhookSecond.topic = "products/create";
webhookSecond.address = "https://api.service.co/items/webhooks";
webhookSecond.format = "json";
console.log("registering products/create");
try {
await webhookSecond.save({
update: true,
});
} catch (error) {
console.log(error);
}
console.log("getting all webhooks");
try {
let webhooks = await Webhook.all({
session: session,
});
console.log(webhooks);
} catch (error) {
console.log(error);
}
Everything works fine for a development store. However, when I try to launch this script on a third-party customer store, then I get this error:
HttpRequestError: Failed to make Shopify HTTP request: FetchError: invalid json response body at https://shopname.myshopify.com/admin/api/2022-04/webhooks.json reason: Unexpected end of JSON input
The app permissions/scopes are: read_checkouts, read_orders, read_inventory, read_products, read_customers
I got this error 3 times, even for Webhook.all.
Could you please tell me what can cause this error, and how could it be fixed?
This error was caused by the lack of access provided by the owner of the store to my collaborator developer account. Manage settings access was required.

how to fix Error: equest failed with status code 400 in react native google signin error 400?

To handle google signin, I'm using the #react-native-google-signin/google-signin package, which worked OK until the request failed with a status code of 400.
For requests, I use the following code.
const googleSignIn = async () => {
try {
await GoogleSignin.hasPlayServices();
const userInfo = await GoogleSignin.signIn();
console.log(userInfo);
} catch (error) {
console.log(error);
}
};
Any help would be greatly appreciated!

NPM instagram-web-api checkpoint required

I have configured the NPM instagram-web-api package. I have instantiated the Instagram object and passed the correct credentials:
const Instagram = require('instagram-web-api');
const { igUsername, igPassword } = process.env
const ig = new Instagram({ username: igUsername, password: igPassword });
(async () => {
try {
await ig.login()
} catch (err) {
if (err.error && err.error.message === 'checkpoint_required') {
console.log(err.error);
const challengeUrl = err.error.checkpoint_url
await ig.updateChallenge({ challengeUrl, securityCode: 670381 })
}
}
const profile = await ig.getProfile()
})()
I am getting a 'checkpoint_required' error message and each time I start the server a Instagram verification code is sent to my email. I don't know where to enter that code or how to resolve this issue.
Having the same issue. I thing we need to call an extra api for the OTP validation in order to login.
Check this out - https://github.com/ohld/igbot/issues/630 for the solution or reference.