Mobile App Api for Magento (Android/IOS) - api

I am developing a Magento ecommerce website and looking to develop IOS and Android app for my Magento Store. But not sure how to communicate with store via API.
Can any one please let me know step by step guide to write php script (or anything else) to communicate with my store to build app.
Thanks in advance.
Regards

go to magento backend
System > web Service > Soap/xml- RPC users & Soap/xml- RPC roles
create username and Api key and pass these values , Thats all

First of all create a soap user from System > web Service > Soap/xml- RPC users and assign the user to appropriate role.
Then use this structure to call methods:
$client = new SoapClient('http://1tamas-dev/api/soap/?wsdl');
$session = $client->login('soap_user', 'soap_password');
$result = $client->call($session,'catalog_product.list');
You can find more information on magento documentation:
http://devdocs.magento.com/guides/m1x/api/soap/introduction.html

Related

How to use the eBay Browse API just to search for products via one server

I try to migrate from eBay Finding API to Browse API. My technical setting is quiet easy:
A Server searches the Browse API to find products by a keyword. Thats it.
Does anybody know if I need to implement OAuth, a redirection page for eBay-Users to log in etc.? I don't need all those features..
Thanks!
You can use the browse API with the client credential flow that mints the Application access token.
Application tokens are general-use tokens that give access to interfaces that return application data. For example, many GET requests require only an Application token for authorization.
See Documentation
The client credential flow does not require a User to Login via eBay and the redirect etc. However, you can only use the "GET" methods like getItem, getItemByLegacyId or search for example.
If you using NodeJs or Browser you can checkout the "Get Item" example here. (The library will get the Application access token automatically and return the result.)

How to configure Azure AD SSO programmatically for gallery-based application?

I need to configure Azure Active Directory SSO for Tableau Server gallery app as it is under MS documentation link programmatically. Are there useful powershell cmdlets / rest apis?
I create application from gallery using graph api from Step 1 on MS docs.
To get available templates:
GET https://graph.microsoft.com/beta/applicationTemplates
To create template app:
POST https://graph.microsoft.com/beta/applicationTemplates/{id}/instantiate
Now I need to configure SAML SSO from code and assign users. Is there an easy way to do that? I tried Set-AzureADApplication but it didn't do the job for me. The enterprise application is still not set.
Maybe it's not supported yet? I believe there can be some workaround. I would be grateful for any help.
Are there useful powershell cmdlets / rest apis?
Yes, but per my test, we need to do that into two parts.
1.Set the Sign-on URL, to do this, we need to call Microsoft Graph - Update serviceprincipal.
In the Graph Explorer, use the request below.
PATCH https://graph.microsoft.com/beta/servicePrincipals/<object-id of the service principal>
{
"loginUrl": "https://azure.signtest.link"
}
Note: In the request above, you need to use the object-id of the service principal(Enterprise application), not the AD App(App registeration). You can find it in the Azure AD in the portal -> Enterprise Application -> find your Tableau Server -> get the Object ID like below.
2.Set the Identifier and Reply URL, we could do this via Powershell Set-AzureADApplication.
Sample:
$Identifiers = #(
"http://www.tableau.com/products/server",
"https://azure.idtest.link"
)
$ReplyUrls = #(
"https://azure.rptest.link/wg/saml/SSO/index.html"
)
Set-AzureADApplication -ObjectId <object-id of the AD App> -IdentifierUris $Identifiers -ReplyUrls $ReplyUrls
For the object-id of the AD App, navigate to the Azure AD in the portal -> App registrations -> find your Tableau Server. After running the command, the settings will map to the enterprise application.
Check the result in the portal:
Update:
Not sure if it is a bug, if I create a new app without setting the Identifier and Reply URL manually in the portal, then just use the powershell above to set them, they will not map to the portal.
But if we check the service principal(enterprise application) directly via Microsoft Graph, we can see the powershell actually affected the service principal.
If we configure the settings manually in the portal first, then use the powershell to update them with other values, it works.
And it looks there is no way to set the Default Reply URL via powrshell or API, if we set the Reply URL which is different from the one set manually in the portal, it will have a prompt like below.
But if we look into it, actually the Default option is checked.
Update2:
Eventually, I find the trick, it is not a bug, we just need to set the preferredSingleSignOnMode for the service principal first via Microsoft Graph, then we won't need to configure that in the portal manually.
Sample:
PATCH https://graph.microsoft.com/beta/servicePrincipals/<object-id of the service principal>
{
"preferredSingleSignOnMode":"saml",
"loginUrl": "https://azure.signtest.link"
}

Oauth Codeigniter API

Ok i have a project where i need to build a api oauth and to be honest i am completely lost and confused and really in need of some advice to help me get started.
The service i have allows users to create apps which will then generate two keys and store them into a database.
My database has table called apps with 4 fields.
name (VARCHAR 250)
description (TEXT)
key (VARCHAR 250)
secret (VARCHAR 250)
So the user create a app like below.
name = 'myapp';
description = 'Access to my api';
key = '5788334367';
secret = '91708741625783470472';
Now here is the part where i am completely lost building the api with oauth. I want to use https://github.com/chriskacerguis/codeigniter-restserver as i have work with it before to build a api but it was a open api only running get requests and just for me a single user so no apps.
Correct me if i am wrong, oauth is just a framework that you will include like any other library where do i find a oauth library that fit with codeigniter.
I found this which explains the process quite well and has helped http://knpuniversity.com/screencast/oauth but like everything only helps me so far.
The process i have for the api (i think).
When i am a user using my api, they will send of the key and secret to my api.
My api takes the two keys via a oauth endpoint from my codeigniter oauth library via post method checks them against the database and sends a token back which my user can then access the api with.
Just really trying to get started my process please help.
Install codeigniter
Include codeigniters rest api library
Install a oauth library
Setup a function within the oauth library to check my users app keys against the database to check they are valid and return a token
Start to build out the api with endpoints and calls like /api/list_files
My users can then use other frameworks to access my api.
Would love some help to get me of the ground i am completely new to building a full oauth api.
Thanks

Problems working with Google Calendar Api V3 and PHP

I'm just trying to make a little, simple application (that i already made two years ago in Objective-C with api V1) that presents a screen with time of event and description and a button : "insert event in your calendar".
Every user has, obviously, to configure the application with his google username and password.
The app simplifies some process using the first calendar available.
I had infinite problem trying to do it with javascript (this app will be made in html5), so, looking at docs, I ended up trying to make a back-end on my server in php5 (thought it could be easier...ohohoho).
So, i read docs from here : https://developers.google.com/google-apps/calendar/
What i did :
1)
Get to the Google Developers Console.
Created a project.
I now have this (not real keys):
OAuth 2.0
Client ID 352xxxyy9.apps.googleusercontent.com
Email address 3527xxxy#developer.gserviceaccount.com
Service Account
Client ID 3523xxxyy419-vpfgdfg9u77s0.apps.googleusercontent.com
Email address 35ssss9-zzzzsnhavna78ea0b9gvn6a9u77s0#developer.gserviceaccount.com
Public key fingerprints :ac15ddfxdffrtg5565fgfg545r
2)
I installed Google APIs Client Library for PHP (beta) in my server.
doc says:
Using the Google APIs Client Library for PHP requires that you download the PHP source. In the future, packages will be provided. Refer to the project page for more details.
Run the following commands to download and install the source: svn blaj blah blah.
I copied the entire source in my server. Easy :)
Then..
3) You can now import the classes you will need using the following statements:
require_once "../src/apiClient.php";
require_once "../src/contrib/apiCalendarService.php";
Ok, i'll insert them in my php script !
4)" Configure your app"
You must instantiate a client to make requests to the API. All requests to the Google Calendar API require authorization.
The following code demonstrates how to configure an authorized service object using OAuth 2.0 for native applications. For more information, see Authorize Requests.
To find your project's client ID and client secret, do the following:
Go to the Google Developers Console.
Select a project.
In the sidebar on the left, select APIs & auth. In the displayed list of APIs, make sure the Google Calendar API status is set to ON.
In the sidebar on the left, select Credentials.
Find the lines labeled Client ID and Client secret. Note that there may be a client ID without a client secret, for use with Compute Engine and App Engine; in that case, create a new client ID and client secret by selecting Create New Client ID.
Edit the src/config.php file to put in your developer API information.
global $apiConfig;
$apiConfig = array(
// Site name to show in Google's OAuth authentication screen
'site_name' => 'www.example.org',
// OAuth2 Setting, you can get these keys in Google Developers Console
'oauth2_client_id' => 'YOUR_CLIENT_ID',
'oauth2_client_secret' => 'YOUR_CLIENT_SECRET',
'oauth2_redirect_uri' => 'YOUR_REDIRECT_URL',
// The developer key; you get this from Google Developers Console
'developer_key' => 'YOUR_DEVELOPER_KEY',
...
// Which Authentication, Storage and HTTP IO classes to use.
'authClass' => 'apiOAuth2',
....
// Definition of service specific values like scopes, OAuth token URLs, etc
'services' => array(
'calendar' => array('scope' => 'https://www.googleapis.com/auth/calendar'),
)
);
But they are DIFFERENT from the key i have, what's wrong ????
What are client secrets ? redirect_url??
Please help.
I think you need to setup a service account access as described here:
https://code.google.com/p/google-api-php-client/wiki/OAuth2#Service_Accounts
I had difficulties to get it work as I made many trial and errors and my cache got filled with non-working token.
If ever you find yourself not able to access the calendar even after following all the steps, try to change this line of code:
$client->setAssertionCredentials(new Google_AssertionCredentials(SERVICE_ACCOUNT_NAME, array('https://www.googleapis.com/auth/prediction'),$key));
to this:
$client->setAssertionCredentials(new Google_AssertionCredentials(SERVICE_ACCOUNT_NAME, array('https://www.googleapis.com/auth/prediction'),$key, 'notasecret','http://oauth.net/grant_type/jwt/1.0/bearer',false,false));
The last false tells AssertionCredential class to not use any cache. I did it once and then it worked with it set to true afterward.
First go here https://console.developers.google.com/project that is where you configure your app...
Click on your project, then on the left side you will see APIs & Auth, click on Credentials. You will need to create your OAuth, and Public API Access keys.
Once you have done that you will then enter those into the appropriate client_id, secret, redirect etc.
The redirect uri is the same page your app is on, its the page the user gets sent back to after authorizing.
I had the same problem.
On this page, when you click on the Create new Client Id, choose Web application and it shoudl give you the client secret key as well.
https://console.developers.google.com/project
Add a project etc.
Hope it helps

How to use java socialauth in a stateless environment? (without the need to store SocialAuthManager in session)

I am developing a stateless RESTFul API based on JavaEE 6 and it is important not to store anything in the session.
I am using socialauth java based social auth provider.
I would like to know if there is a way to rebuid SocialAuthManager after a successful authentication without having to retrieve it from the session as documentation explains:
session.setAttribute("authManager", manager);
And then:
SocialAuthManager manager = (SocialAuthManager)session.getAttribute("authManager");
I want to avoid this.
I would like to do something like this:
SocialAuthManager manager = new SocialAuthManager(PARAMS TO REBUILD PREVIOUS AUTH WORKFLOW);
Thanks in advance.
I'm developing social auth with 4.10 version of this lib.
After user get redirection url and is authorized, then I do connection to social service by this way:
AccessGrant accessGrant = manager.createAccessGrant(network.getId(), params);
Optional<Profile> profile = Optional.ofNullable(manager.connect(accessGrant).getUserProfile());
manager.disconnectProvider(network.getId());
Where params - params from request of success callback API. After getting user profile I disconnect manager for reusing it. Also be aware of concurrency when using this method.