401 while creating customer in quickbooks using php api - php

I keep getting 401 in spite of using the test keys from the playground app, can someone help on how to resolve this, code works fine on a dev server, as soon as code moved to qa server i created a new QuickBooks account and a new app and now i keep getting a 401

Just moving code from one server to another is a guaranteed way to break anything OAuth related.
You would need to at least:
Move the code
Change the OAuth URLs in Intuit's control panel to point to the new server
Change the OAuth URLs in your code
Clear any stored OAuth access tokens from your database (if you moved the data in the database to the new server as well)
Reconnect to QuickBooks, via the [Connect to QuickBooks] button
Additional notes:
Why are you using test keys from Intuit's playground app? Create your own app, and use your own keys.
If you created a new app, you'll also need to swap our your OAuth consumer key, OAuth consumer secret, and App token in your code.
Be aware that if your app is in DEVELOPMENT mode, then you can only connect to DEVELOPMENT QuickBooks accounts. If you created a LIVE QuickBooks account, you can only connect to it with PRODUCTION/LIVE app credentials (e.g. you need to PUBLISH your app).
Since you didn't post:
Your code
Screenshots of the credentials from Intuit's control panel (assuming they are dev/sandbox and thus safe to post)
Any of the HTTP requests/responses you're sending/receiving
We won't be able to really help you much further.

Related

Single sign on based on PHP not working in google app engine

First we took the SAML code sample references from https://github.com/onelogin/php-saml and set up the integration with our project.
Before going to company SSO, we created trial account with a third party service provider one login, to test our code for Single sign on is proper.
On local this worked perfectly. We deployed same on GCP with changed references and test failed.
Next we went with our company SSO on GCP with certificates and necessary changes. It failed in similar manner as as not authenticated
When the site is accessed redirection to company sso OK
Successful Authentication at company SSO and redirection back to Application OK
Validating the response from company SSO in the application NO
On using SAML Tracer it was clear that the authentication at the company SSO side was proper, only that our code wasn’t able to receive it properly.
Since on local things are working as intended we doubt with respect to GAE/PHP we may be missing something as the application cannot verify the object returned from SSO, may be losing cache/session.
we are using Google app engine standard with our application being PHP 7.4

Connection refused for URI https://www.googleapis.com/oauth2/v4/token

I am new to GoogleAPIs and Laravel, I run a PHP web application on Laravel 8 in a virtual Linux environment. Socialite and Drive API was working fine and out of sudden it doesn't work anymore and always return connection refused error after long period of loading as follows:
GuzzleHttp\Exception\ConnectException
Connection refused for URI https://www.googleapis.com/oauth2/v4/token
I had tried to create a new credential with new refresh token and checked all the network settings, and always clear config cache and restart apache for all troubleshoots I have tested, yet the error still exists.
I would appreciate it much if anyone could enlighten me on what are the aspects I shall look into it.
There are multiple issues in this question.
First and foremost, you are sending your secret to a third party. This means that they are able to do any API calls as you (using your name and quotas). Even if they claim that they won't, they can. Please remove any secret you may have and create new ones.
As for the OAuth 2.0, you seem to be using an old URL. You should probably take a look into the official documentation for:
Using OAuth 2.0 to Access Google APIs for a basic explanation.
Using OAuth 2.0 for Web Server Applications for making a web and getting permissions to get/modify a user's data (can be yourself).
Using OAuth 2.0 for Server to Server Applications for using a service account to execute as one of the users on your organization, without the need of manually giving permission.
Also notice that there are PHP libraries officially supported by Google to make your life way easier. See the Drive API's PHP Quickstart.

How to get OAuth client key and client secret to android app at runtime without hard-coding

I need to find a way to authorize an android client with a wordpress API at runtime using OAuth, without hard-coding the client key and client secret.
I added a new application in wordpress and generated a client key and client secret. In addition to that, I installed the "Wordpress REST API - OAuth1.0a Server" Plugin.
As for now, the client key and secret is hard-coded inside of my android project. I successfully authorized my android client with these credentials using OAuth1.0a and can make requests to the API.
However, multiple android clients should be able to connect to different wordpress API's.
After the app is build only once, a client should have the ability to get the client key and secret for a specific Wordpress site to initiate an OAuth authorization.
Therefore, the client key and secret need to be specified somehow during the initial setup process at runtime.
Is there a better to do this, other than manually typing in the client key and secret?
I really feel like I'm overlooking something quite obvious, but couldn't find the answer yet.
Thanks in advance!

Choosing the right oAuth2 grants

I'm building a REST API using Symfony2 (FOSRestBundle and FOSOAuthServerBundle) and I'm unsure on which grant type to use for this service.
I will have other developers register as users. I was looking at GitHub, and for each user they have a section called 'applications' in their settings which allows adding an application and it gives back client_id and client_secret. But AFAIK GitHub uses the authorization grant type which means you're sent to GitHub to accept and then redirected back to your application with the auth code (does the auth code live forever or what?). I'm not sure if this is what I'm looking for.
What I want is a way to allow developers to consume my API with me knowing who is accessing (FOSUserBundle integrates pretty well here) and what they are allowed to do.
Also, I'll have my own browser based application, Angular.js probably which is the main website where developers can register. It will make API calls to present data for whichever dev logs in. I could use a Node.js backend (need it for some other stuff) so the actual calls are made from there instead as it seems browser only applications aren't really safe. I was thinking of using client credentials grant type from the Node.js backend.
And last, I'll have my own mobile app interacting with the API. Since it's a trusted service it should use Resource owner credentials grant, right?
I'm not sure I understand what you ask for here. As I understand it your developpers will have an account on which they will have to log in in order to use your API. In this case Client Credentials does not seem appropriate, since it would not identify a developper but a client. A client does not represent a user, it represents "an application that accesses your API" (it, in your case you would have one client for your mobile App and one client for your Angular website). I would use a password grant type, that does not redirect you to an external service.
When I had to implement a OAuth2 authentication for my API, I found this article very helpful, it is based on a Symfony2 example but most of the explanations apply everywhere.

How to access Google Play Android Developer API through backend server

I am implemented In App Billing for android.I wanted to implement subscription validity checking through my backend server. As Google Play Documentation, for making call for Google Play API,need authentication using oauth 2.0.
I followed instructions for registering project and creating credentials. But from there I have no idea how to use those credentials, I tried authentication via CURL request, but it asking permission as shown in follwing image
This permissions works fine I can exchange code and get access token, but all this done by manually, how should I implement this on backend.
I even try to use google api php library provided by Google, but It adds confusion. Also they didn't provide any example, how to use library.
Can anybody elaborate how exactly use library or pure php?
Thanks in advance.
To perform LVL and/or IAB validation on a server, do not access Google servers directly from the server. Even if all information were available, you would face integrity problems, because your app and your server will see different information due to synchronization latencies.
Instead, use your app as a proxy and validate the Google Play information on your server as described here.

Categories