Login and pay with Amazon integration issue - javascript

So, I'm trying to integrate the Login and Pay with Amazon widget, and I'm encountering some problems.
So, I have my seller account all set up on
https://sellercentral.amazon.de/gp/
I have access to my API credentials, and I need to get a LWA client.
So, I have registered on
https://sellercentral.amazon.com/gp/homepage.htm
in order to create an application. I have set up the application, on web settings I have completed the required URL's, and got my client ID.
In the js for the Login and Pay with Amazon widget, I have replaced all the info needed: Client Id, merchant Id etc.
But when I try to make a test login, I receive the following error :
400 Bad Request Unknown client_id
The Pay With Amazon documentation is not very clear, and I can't seem to find anywhere a list with the error codes.
If anybody has an idea, let me know.
Thanks!

you should create your Login with Amazon application using https://sellercentral.amazon.de instead of the .com site. They are separate accounts.

It sounds like you're missing this piece of code:
window.onAmazonLoginReady = function() { amazon.Login.setClientId('CLIENT_ID'); }

Related

Why my geoip query doesn't work in my production server?

I'm getting a hard time making Maxmind's geolite2 geolocation work on client side.
First I found this page: https://dev.maxmind.com/geoip/geolocate-an-ip/web-services?lang=en
And tried to use the urls in the curl command with authentication with my generated license key:
let geoData = axios.get('https:///geolite.info/geoip/v2.1/country/me?pretty', {
auth: {
username: <myuser>,
password: <mylicensekey>
}
});
this works in node but in client-side I get a CORS error.
then I found this other page: https://dev.maxmind.com/geoip/geolocate-an-ip/client-side-javascript?lang=en
It worked but I didn't want to use a non-npm packaged lib, so I inspected the lib's source-code and saw it call a different url from above:
https://geoip-js.com/geoip/v2.1/country/me?
trying this new url I saw it worked only WITHOUT authentication. I didn't understand why but anyway... it worked. Until I send the code to production at least.
With localhost it worked ok, but in production I get an error saying I have to register my domain.
The link provides in "register your domain" in this page: https://dev.maxmind.com/geoip/geolocate-an-ip/client-side-javascript?lang=en
leads to https://www.maxmind.com/en/accounts/790937/geoip/javascript/domains which asks me to enter the paid service registration page: https://www.maxmind.com/en/accounts/790937/geoip/javascript/domains
Is that it ? Client-side geolocation is only available as a paid service ?
So I want to know:
If there is a way to register domains for the free service, where do I register my domain?
If I can use https://geolite.info/geoip/v2.1/country/me?pretty url with id and license key in client-side, how to I get rid of the CORS message ?
I want to get the data without sending the user's IP, like when we access https://geolite.info/geoip/v2.1/country/me?pretty with id and license key.
Currently I want to use MaxMind's free data.

How can I set custom signatures across a domain Gmail API

I want to set the signature for all users on my Google Apps domain to their name and job title.
Through my research, I found that the only free way to do this is by using the Gmail API.
I managed to get a list of all users on the domain (with the required info, email address that I want to set the signature of, name, job title) simply by using the quick start guide at https://developers.google.com/admin-sdk/directory/v1/quickstart/js.
At the end of the listUsers function I added the loadGmailApi code.
Once the api is loaded, it runs a funtion called setSignatures.
function setSignatures() {
var request = gapi.client.gmail.users.settings.sendAs.update({
'userId': email,
'sendAsEmail': email,
'signature': '<strong style="color: rgb(230, 145, 56); font-family: arial, sans-serif; font-size: large;">' + name + '</strong>'
});
request.execute(function(resp) {
console.log(resp);
});
}
This works perfectly when the variable "email" is my own, but when it is anyone elses, I get the following error: 403 Delegation denied for 'myemail'. I am a super admin.
I now found out I need to use a service account.
I then completely followed this guide How to obtain Google service account access token javascript.
The one difference is that to authorise I use
gapi.auth.authorize({
instead of
gapi.analytics.auth.authorize({
As I don't need the analytics API. I hope that isn't causing problems. I need the directory and gmail API.
At the end of the code provided in the above link, I loadDirectoryApi() and run code to get all the user information again, as before. I can't even get to setting the signatures, because at this point, I get an error saying : 401 Login Required.
So if I use my own email to try this, I get a 403, and when I tried a service account, I got a 401. It says login required, how can I log in? I thought service accounts don't actually log in, but I use a JWT to make an access token.
I am authorising by
gapi.auth.authorize({
'serverAuth': {'access_token': token},
'scope': 'https://www.googleapis.com/auth/admin.directory.user',
'client_id': 'myClientID'
});
What am I doing wrong? Please help. I need to know how to "log in" or authenticate with a service account so that I can update signatures.
Even if you are super admin you cant change email signatures of other users by default using gmail api.
First you need to create a service account in google dev console and add domain wide delegation for that account.
After that you go to your google admin and add that service account with required scopes under API control.
Then you need to use those credentials inside of your python script.
Basically what it does is, it allows you to impersonate as other user and change email Signature. You don't need password as the service account has domain wide rights. The below link explains how to do that.
But the link describes it using PHP but still it will help you to create a domain wide delegation service account.
https://moometric.com/integrations/gsuite/use-gmail-api-update-signatures-gsuite-users-php/

how to get account details when integrating plaid api

I am actually trying to integrate Plaid api for ACH payments and following "https://plaid.com/docs/link/" tutorial in Ruby. In this I have written the js code and it shows me pop up to select bank accounts.
I am using it in sandbox mode in which I am using test credentials to verify the account and it successfully verifies the account. For server side scripting I have installed plaid gem and configured it using following code into my_app/config/initializers/plaid.rb
Plaid.config do |p|
p.customer_id = 'test_id'
p.secret = 'test_secret'
p.environment_location = 'https://tartan.plaid.com'
end
where I have replaced the customer_id and secret key with my own. I am using a user controller in which under create method I am trying to create a user like this:
user = Plaid.add_user('auth', 'plaid_test', 'plaid_good', 'usaa', '1234')
Now I am confused how would it work.
I am trying to create a server side handler using ruby but I dont understand where I am lacking (as I am new to Ruby). I actually want that after successfully validating credentials there should be an option to select account like in the given demo
https://demo.plaid.com/stripe
I really need help as I am badly stuck in this from last three days. Any help would be appreciated. Thanks
Plaid Link returns a 'public_token' - you'll need to use the /exchange_token API endpoint to exchange the public token for an API access token.
The plaid-ruby library has a detailed example of the exchange token flow!

Google access_token is undefined

I am developing a mobile web application which will access the Google Books API and allow the user to add books to their "favorites" book shelf. Its my first time using an API that requires the Google authorization.
I need to send an authorized request to modify private user data. I (think) I have have the proper access_token but I can't figure out how to get to it.
I am using the Google sign in button like so:
` <div class="g-signin2" data-onsuccess="onSignIn"></div> `
I also have this to identify my application to Google:
`<meta name="google-signin-client_id" content="12345.apps.googleusercontent.com"> `
I sign in with my own Google account and the Google button changes over to "Signed In." I am simply trying to log the access token from there:
` function onSignIn(googleUser) {
googly = gapi.auth2.getAuthInstance();
var id_token = googly.currentUser.get().getAuthResponse().access_token;
console.log(id_token);
} `
I've tried everything I can find in the documentation but no matter what I do, I get back that access_token is undefined.
My suspicion is that I don't actually have an access token, but I don't know how to test that.
What is the correct way to find the access_token? Once I have it, how do I send it to the API?
It's so late but if you pass true parameter to getAuthResponse "getAuthResponse(true)" it returns access_token.
Try using gapi.auth in the API Client Library instead of gapi.auth2 in the Identify Platform. You should find gapi.auth.getToken().access_token contains the access token you need.
That said, I believe this is a bug. If you alert(JSON.stringify(googleUser)) I suspect you'll find there is an access_token field buried in there, but getAuthResponse() doesn't contain it, even though the docs suggest there should be one.
If anyone can confirm I'm understanding this correctly and report it, that would be great.
If you include the response_type in the request header as 'token' it will return the access_token with the currentUser

Facebook Page has a fan or not

Im trying to use javascript to determine if a user is a fan of a page that i've created on my account.
I found the facebook graph api which looks like just what i want. However it appears for some functionality i need an access token.
Here it says I can just http get my /user_id/accounts page with the manage_pages permission and it will list the access token for each page.
But when i submit https://graph.facebook.com/myuserid/accounts&scope=manage_pages i get "OAuthException : Access token is required to request this resource."
I also tried from this answer, but then i get "An error occurred, please try later".
Any suggestions most welcome.
You will need an access token to retrieve any information that is not public on facebook.
You can read up on this page about authenticating a user. Once your user is authenticated you can retrieve the access token and use it in your future requests (for that user)..
eg:
https://graph.facebook.com/{YOUR_USER_ID}/accounts&access_token={YOUR_ACCESS_TOKEN}

Categories