Bigcommerce app - How to change the Auth Callback URL - php

I am new to Bigcommerce app
From the sample github,
https://github.com/bigcommerce/hello-world-app-php-silex
How to give the
Auth Callback URL: https://<app hostname>/bigcommerce/callback
Load Callback URL: https://<app hostname>/bigcommerce/load
Uninstall Callback URL: https://<app hostname>/bigcommerce/uninstall
where,
<app hostname> represent
http://localhost/repo/hello-world-app-php-silex (or)
http://XXX.mybigcommerce.com/hello-world-app-php-silex
In the point 5,
they mentioned as "Restart the software or the entire host as needed to set the environment variables." How to restart ?

When you add the Auth Call back URL's to your .env file as per the example. You need to restart the web server. That is the point mentioned on the GitHub page.
BC_AUTH_SERVICE=https://login.bigcommerce.com
BC_CLIENT_ID=<contents of Client ID field>
BC_CLIENT_SECRET=<contents of Client Secret field>
BC_CALLBACK_URL=<URL TO YOUR AUTH CALLBACK ENDPOINT>
Also, note that the BC_CALLBACK_URL has to be the same you setup in developer portal when you configure the app.

Related

Shopify: There’s no page at this address Check the URL and try again, or use the search bar to find what you need

I’m new to Shopify App development. I’ve developed an app using a php template provided by shopify. It’s using Laravel & React. It’s https://github.com/Shopify/shopify-app-template-php/tree/cli_three
When I execute npm run dev, the app is running in the development store.
Then, I deployed my app on the AWS server using one domain (e.g: sub.mydomain.com).
Before deployment:
I have build the frontend using: SHOPIFY_API_KEY=MY_API_KEY npm run build
I’ve run composer build too.
After that, I tried to install the app. While doing so, It’s authenticating and saving the session in the database too.
But, on redirecting after authentication, it’s not working,
First, It’s giving this error on console:
Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://mystore.myshopify.com') does not match the recipient window's origin ('https://sub.mydomain.net').
And then after redirect, it’s displaying:
Along with console error:
GET https://mystore.myshopify.com/admin/apps/40aac89c4c56232219d0f1f75a1f2ae7/?hmac=68236dae6688aafd05925cf409dfff0965236542401999f8ff47decd8b942d&host=cW9kZWFuYWx5dGljcy5JKihgZnkuY29tL2FkbWlu&shop=mystore.myshopify.com&timestamp=1657698129 404
About that console error you need to add this header on top of the page in views top_level.blade.php
<?php
$domain= $shop ?? Auth::user()->name ; ; // loged-in shopify store url example.myshopify.com
header("Content-Security-Policy: frame-ancestors https://".$domain." "."https://admin.shopify.com");
?>
This will resolve the does not match the recipient window's origin error.
After that try to open the app again or you can remove the entry from db and install the app again hope that will help.

Wordpress REST API Issue

I'm currently trying to wrap my head around Wordpress and its relation to the REST API. All of theses issues are only occurring in the context of plugin development. So far I had setup my endpoint and written my callback which will be executed whenever someone is sending a GET-Request to said endpoint. However, my callback is never called. This is the file which I've written so far.
/*
* Plugin Name: cola-learning
*/
if(!defined('ABSPATH')){
die;
}
if(!function_exists('add_action')){
echo 'You cant access this ressource!';
exit;
}
function PrintRESTResponse()
{
return rest_ensure_response("student");
}
function SetupREST()
{
return register_rest_route("student/v1","/view/",[
'methods' => 'GET',
'callback' => 'PrintRESTResponse'
],false);
}
add_action('rest_api_init','SetupREST');
Perhaps it might also help, if I'll give some background information about my development machine:
- OS: Windows 10
- Server: Apache Web Server (included inside XAMPP)
- Wordpress Version: 5.3.2
- PHP Version: 7.4
- Development IDE: Eclipse 2019-12 CDT ( with PHP Plugin )
From my research, everything should work fine. However, it doesnt :/ Did I miss something crucial?
Update:
WordPress REST API Routing
WordPress is having a default route for all request which are directed to the REST API ( at least if you use XAMPP with the Bitnami WordPress application module). Now, if one wants to send a request to said REST API, the person needs to use an URL with the form of ip:port/wp-json/rest_route. ip ressembles the ip address of the server which is hosting wordpress. port is the port of said server. wp-json, however, is the portion which differs an ordinary request from a request to the REST API. Everything after this portion (rest_route) is the rest route which I've defined in the above source code.
What went wrong?
My request was pointed to the wrong endpoint. Therefore I used the URL 'localhost:wpPort/wordpress/student/v1/view/'. However, the 'wp-json/' portion is missing. Therefore WordPress will search for a page that doesn't exist in the first place. Instead I should have used the URL 'localhost:wpPort/wordpress/wp-json/student/v1/view/'.
After some troubleshooting it turns out the URL being used to test was missing a part of the endpoint path.
Here is the correct path to test the newly registered endpoint.
localhost:80/wordpress/wp-json/student/v1/view/
Here's some more reading on WP Rest API endpoints:
https://developer.wordpress.org/rest-api/extending-the-rest-api/routes-and-endpoints/

Facebook App - The domain of this URL isn't included in the app's domains. Why?

When trying to login with a Facebook app, I'm getting the following error:
Can't Load URL: The domain of this URL isn't included in the app's domains. To be able to load this URL, add all domains and subdomains of your app to the App Domains field in your app settings.
As you can see on the following image:
URL: http://www.facebook-php-test.com
Below is the configuration I have set on my Facebook App.
(Notice: for privacy purposes I changed the values for App ID and App Secret on the image)
The code for this basic sample application is on this GitHub repository:
https://github.com/zeuscronos/facebook-php-test.com
I really don't know why it says that the domain of this URL isn't included in the app's domains when it is actually there.
On the field: App Domains I tried with both domains at the same time:
facebook-php-test.com
www.facebook-php-test.com
but no success.
The generated login URL is as follows:
https://www.facebook.com/v2.10/dialog/oauth?client_id=012345678901234&state=d3758e484d539bebd6505427aaf1fa3b&response_type=code&sdk=php-sdk-5.6.1&redirect_uri=http%3A%2F%2Fwww.facebook-php-test.com%2Ffb-callback.php&scope=email%2Cuser_friends%2Cuser_photos
I configured the domain: facebook-php-test.com as a virtual host on an Apache server.
I have to say that I have worked a lot with the Facebook PHP SDK and this is the first time I'm getting struggle with this. Actually, I got this problem with another big application I was working with then after couple of hours trying to solve the problem I created this dummy application to try to figure out what's the cause of the problem.
I have tried many things with no success.
Any idea on how to solve this?
Thanks.
EDIT 01
Following the suggestion of Mr.Geeker comment I did the following...
Added the product: Facebook Login and configured like below:
Then, finally I could go forward, and I was asked for permissions:
But unfortunately, after granting permissions, I got the following:
Any idea on how to continue from this point?
EDIT 02 - SOLUTION
I ended disabling the option: Use Strict Mode for Redirect URIs under Client OAuth Settings. They say it is strongly recommended has this feature On but I could not get this working with that On.
By the way I also disabled: Client OAuth Login since my app doesn't use it.
Finally, the only feature I have enable under: Client OAuth Settings is: Web OAuth Login.
Facebook now roles some features as plugins. In the left hand side select Products and add product. Then select Facbook Login. Pretty straight forward from there, you'll see all the Oauth options show up.
As originally answered here
On March 2018, facebook updated the API and forced all apps to keep strict mode On.
To make it work, you have to include the full callback url in the Valid OAuth Redirect URIs field. If you redirect to "https://www.example.com/facebook/callback", the full URI must be included (without parameters):
The domain must be set in the App domains and the Website Site URL fields on the basic settings page:
If none of these works and the "Can't Load URL: The domain of this URL isn't included in the app's domains." message keeps showing, check if you have the latest version of the SDK. I could make it work after updating de PHP SDK from version 5.5 to 5.6.2
I'm using PHP 5.5 and I found the bug.
The PHP Facebook API VERSION = '5.5.0', DEFAULT_GRAPH_VERSION = 'v2.9' was adding the URI ?code=XXX in my callback page like this:
mydomainExample.com/callbackFacebook.php ?code=XXXXXXX
and I changed the source code to remove the string after '?'. Now the callback url is only
mydomainExample.com/callbackFacebook.php
The fixed can be done in the file Facebook/Helpers/ FacebookRedirectLoginHelper.php inside the getAccessToken function. I added a 'if' as below in the line 226 and the issue gone:
$redirectUrl = $redirectUrl ?: $this->urlDetectionHandler->getCurrentUrl();
//the next 3 lines was added to avoid the bug (fixed)
if(strripos($redirectUrl, "?")){
$redirectUrl = substr($redirectUrl, 0, strripos($redirectUrl, "?"));
}
// At minimum we need to remove the state param
$redirectUrl = FacebookUrlManipulator::removeParamsFromUrl($redirectUrl, ['state']);

facebook app can not find my localserver redirected url

I working on third party social login facebook by using django-social-authpackage. But when try to login bellow error show .
I also use django-allauth package and for that i use answerme facebook app.But same problem shown there also.
Facebook server will never find your local server because your website is not live and if you are running localserver then that means that is available to you only and the other person or Machine will not be able to access your server which local. so, to provide your url as callback url you will have to host your local server somewhere globally so, that Facebook can go through that and give results in response to that.
In Settings -> basic set http://localhost:8000/
In Django settings set:
SOCIAL_AUTH_FACEBOOK_KEY = your key
SOCIAL_AUTH_FACEBOOK_SECRET = your secret key
Also in case of success or fail you can redirect the user using this settings.
For finish SOCIAL_AUTH_LOGIN_REDIRECT_URL
For fail SOCIAL_AUTH_LOGIN_URL

Twitter OAuth failing to work (PHP)

I have the TwitterOAuth class and demonstration running on a local development server and I cannot get it to authorize. I have entered the new CONSUMER_KEY and CONSUMER_SECRET in the config.php. I have also synced the server time to NTP. I get the error message: 'Could not connect to Twitter. Refresh the page or try again later.'
var_dump($connection->http_code);
results:
int 0
ANY help or advise would be appreciated.
I am running PHP 5.3
When I try to ping the api server I can't.
C:\Users\Owner>ping api.twitter.com
Ping request could not find host api.twitter.com. Please check the name and try
again.
could this be the problem ?
I had some issues with this process as well. I don't exactly recall what resolved this error, but I followed This Tutorial (albeit a bit out of date) and made sure I explicitly set the callback URL in the twitter panel for my app. Also, and I believe this one also caused the int 0 return for me, make sure that if you are going with a hosting provider they allow CURL requests.
step 1: https://apps.twitter.com/app or go to your app setting
step 2: Unchecked the (Enable Callback Locking (It is recommended to enable callback locking to ensure apps cannot overwrite the callback url)) This box..
save and exit and check..
ThankYou..!

Categories