I want to implement Google Checkout in my PHP project (running on Apache). I put the callback URL in my merchant center account. My Checkout is in sandbox mode. When placing an order I get the following error message in my merchant center:
We encountered an error trying to access your server at myurl.org -- the error we got is
Send failed with code: 401.
Response body was: Failed to Get Basic Authentication Headers
Since neither version of this question has been addressed, I figure I'll add some advice to the one I edited:
I'm not at all familiar with Google Checkout and its API, but a quick Wikipedia search for HTTP error informs me that a 401 error is because authentication has failed. Note, this is not the same as the authentication being rejected (error 403: Forbidden) but rather that the actual attempt to authenticate failed. A good analogy might be to imagine going to a door, being asked for the secret password (which we'll say is Fedelio) and instead of saying "Applesauce" and getting beat up for trespassing (error 403) instead you respond with "Huh?" and the gate keeper simply stands there wondering if you even know what he meant by password.
The same wiki article refers to Basic Authentication in relationship to this error. I highly reccommend taking a look into that as well.
Long story short, your users need to authenticate when the URL is requested, but it sounds like you are trying to request the site server-side or through some kind of redirect, so the server is returning the 401 error instead of returning a login prompt.
Related
I'm trying to use PHP (specifically the SDK made by tangent solutions: https://github.com/TangentSolutions/PowerBI-SDK-PHP/) to push data to a Power BI application (into https://app.powerbi.com) I'm working on. I'm able to get an access token using client_credentials and can run the test API calls Microsoft put into the documentation, however in my application I consistently get this 401 Unauthorized error just trying to run the API call for getting the datasets. I'm testing the datasets call for now, but I get the same response from other API calls too. I also can get the access token when running in Postman and get a 200 response. I've granted the permissions properly (as far as I can tell) in AAD:
I saw some people say to use password as a way of gaining access, which I tried, but I still get 401 Unauthorized back. I would prefer to use client_credentials though, so I'd rather not go this route.
I have not added any scopes to my registered app, because honestly this is the first time I've used AAD and I'm fairly new to using APIs, so I am not totally sure what that means or what I would enter in as a scope. I would think not having scopes could be a problem, but again, I was able to run the test API call from Microsoft's online documentation, which I'm not sure if that's an indication that it should work for the REST API.
The only other issue I can think of is I'm using the Power BI free account, and I'm not sure if I actually need the Pro account in order to build this. I haven't been able to find a straight answer about this, but if anyone knows if Power BI on https://app.powerbi.com uses the "embedded REST API", then I may just need to upgrade my account. I didn't want to upgrade my account just yet if the problem is I'm missing something else.
Usually the 401 error means that the audience of your token does not match your api. When you use the token to call the api, you will receive a 401 unauthorized error. The access token is issued based on the audience, so you must Make sure to set the scope to your api when you request the token. Of course you can also parse the token, check the aud claim, and make sure it is the api you want to call.
If you need to call the Power BI Service api, you should put https://analysis.windows.net/powerbi/api/.default in the scope.
Parse the token:
I am trying to create code for sending document for signature request using docusign API:
I already downloaded the PHP SDK
I already opened a developer sandbox account
But after filling in some info in the PHP SDK file and run, it gave me the above error.
I am guessing the error may mean that I have not gone through the steps to configure client and request authorization code.
I tried to follow the steps on that page, but the instructions are so vague and difficult to follow. I clicked on the 'use sandbox account data' on the upper right corner of the C# code, but it only asked me to log in to my account and directed me back to the same page.
I don't know where to start from there.
I need a more step-by-step instruction.
Thanks
#T. Nguyen 401 translates to an unauthorized API request and the response should say which part is wrong aka the username / password or Integrator Key is incorrect.
I really suggest using PostMan Client and / or SoapUI to validate you can get login information and see the actual error returned, as it will say Integrator Key or Username/Password in the response. PostMan or SoapUI will issue the actual API calls successfully (Demo or Prod once you have passed prod API certification) showing you the actual response without having to worry about coding typo's, properties of objects or debugging logging to see what really came back.
This allows you to learn the DocuSign API while using the PHP SDK. You did the right thing asking for help here on Stack Overflow.
I have a couple links for you to get started:
DocuSign Developer Center where you probably found the PHP SDK https://developers.docusign.com/esign-rest-api/sdk-tools
Link for info on PostMan (older version, you can get the latest one - aka Orange Rocket Man logo vs blue world, for Chrome or Mac Standalone - https://blog.grigsbyconsultingllc.com/postman-rest-client-a-google-chrome-app/
X-DocuSign-Authentication Header Q&A on StackOverflow How should the header X-DocuSign-Authentication be used for REST and SOAP?
I like the concept of the DocuSign API explorer to start with, sad part is it doesn't work against prod, so you still have to use something else when you move from demo to prod.
Best of Luck and Enjoy your DocuSign API journey!
You can set $config->setDebug(true) in dev environment and have all the errors displayed.
to fetch error use this
try{
//send request
}
catch (DocuSign\eSign\ApiException $ex){
print_R($ex); //<--- print normal readeble error
echo "Exception: " . $ex->getMessage() . "\n";
}
I am new to using Square APIs and am attempting to integrate the PHP version of the API into a website.
I have followed the instructions on their site to the best of my ability, utilizing Sandbox credentials including the location ID. The payment form is created, I fill in the form using the fake credit card information provided in the documentation, I receive the javascript alert indicating the nonce has been created, but receive the following error:
Caught exception!
Response body: null
Response headers: null
Can you please provide me with some guidance on how to fix this?
Square Connect Only allows connections from secure sites. Make sure your site has ssl certificate installed.
My guess is you are testing on localhost, in that case you try to generate the self signed certificate. Although I dint try generating my own certificate. I just tested it on live website with ssl certificate and that error was gone.
If you are using the php api v2 sample try printing out the full response by placing print_r($e); in the catch block and view the full description of your errors. Thats how I figured out the problem.
Hope it helps.
I've been struggling quite a bit to solve the this issue. Basically, I'm just trying to connect to my youtube channel and get a list of future and past live broadcasts from my PHP based application. I was able to create a service account on the api console and it seems to be working fine now (as I've had some oauth authentication errors before) but now, I'm receiving this error in my error log:
Uncaught exception 'Google_Service_Exception' with message 'Error calling GET
https://www.googleapis.com/youtube/v3/liveBroadcasts?part=id%2Csnippet&mine=true:
(403) The user is not enabled for live streaming.' in etc...
My youtube account is associated with my personal #gmail.com account. I'm assuming that somehow I have to add the #developer.gserviceaccount.com to my youtube channel but even though I've tried to find any instructions for this, I was not able to find. I have live streaming enabled on my personal gmail account and also have some test events there.
Would appreciate and help in this matter please. Thanks!
Not sure if this will help, but in my case it turned out to be that the account somehow had 2 accounts:
a page with a strange page-id#pages.plusgoogle.com and
a normal Google email account user#gmail.com).
On top of that, I had issues with not renewing the access token: e.g sending an old access token.
Make sure you try the 2 sub accounts; one must have the videos under it. If you choose the wrong one, then you get that error above.
After many many hours searching I am still unable to figure out why I am receiving this error. It worked for a month and without touching any code, stopped working last night. The web app has been registered and Google+ api is turned on.
Fatal error: Uncaught exception 'Google_ServiceException' with message 'Error calling GET https://www.googleapis.com/oauth2/v2/userinfo?key=MYKEY: (403) Access Not Configured. Please use Google Developers Console to activate the API for your project.'
I enabled Google+ Domain API just to see if it did anything. It allowed me to login 1 time and then continued to fail after that.
The developer key should be OK to pass every time as long as it matches the project that has been used for sign in (e.g. the client ID and the key come from the same developers.google.com/console project).
There was a problem yesterday with the userinfo endpoint that caused 403 for a number of users - that has now been resolved, but my guess is you were hitting that unfortunately!
So after further research and testing, I think I have the solution.
As mentioned by Jason OOO, $client->setDeveloperKey($key); was causing the problem.
As it turns out, Google PHP library needs $client->setDeveloperKey($key); passed the first time for validation, but causes an error if passed again after already being validated.
So, to fix this problem, check to see if user is already logged in and if they are do not pass $client->setDeveloperKey($key);