2017 © Pedro Peláez
 

library magento-oauth

Magento OAuth Test

image

jonnyw/magento-oauth

Magento OAuth Test

  • Monday, February 17, 2014
  • by jonnyw
  • Repository
  • 2 Watchers
  • 6 Stars
  • 2,060 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 2 Open issues
  • 3 Versions
  • 5 % Grown

The README.md

magento-oauth

A service class for Magento OAuth using the Lusitanian PHP OAuth library., (*1)

Total Downloads Latest Stable Version Build Status Scrutinizer Quality Score Code Coverage, (*2)

0.0 Table of Contents

  • Examples
  • Changelog
  • Troubleshooting

1.0 Examples

A working example can be found in the examples/ directory of the repo., (*3)

You can create your own instance of the Magento service or use the service factory in the Lusitanian OAuth library, which ensures all dependencies are injected into the service:, (*4)

<?php

use OAuth\Common\Storage\Session;
use OAuth\Common\Consumer\Credentials;
use OAuth\Common\Http\Uri\UriFactory;
use OAuth\ServiceFactory;

$applicationUrl     = 'http://magento.local';
$consumerKey        = 'd19e5e1ce0a8298a32fafc2d1d50227b';
$consumerSecret     = '7c230aba0da67e2ab462f88e6e83ee39';

$storage        = new Session();
$uriFactory     = new UriFactory();

$serviceFactory = new ServiceFactory();
$serviceFactory->registerService('magento', 'JonnyW\MagentoOAuth\OAuth1\Service\Magento');

$currentUri = $uriFactory->createFromSuperGlobalArray($_SERVER);
$currentUri->setQuery('');

$baseUri = $uriFactory->createFromAbsolute($applicationUrl);

$credentials = new Credentials(
    $consumerKey,
    $consumerSecret,
    $currentUri->getAbsoluteUri()
);

$magentoService = $serviceFactory->createService('magento', $credentials, $storage, array(), $baseUri);

By default the service class authorizes users in the admin scope. To authorize customers simply set the authorization endpoint on the Magento service after instantiating it:, (*5)

<?php

use JonnyW\MagentoOAuth\OAuth1\Service\Magento;

$magentoService->setAuthorizationEndpoint(Magento::AUTHORIZATION_ENDPOINT_CUSTOMER);

2.0 Changelog

3.0 Troubleshooting

If you receive a 'Server can not understand Accept HTTP header media type' error message when making API requests through the service then you may need to add an 'Accept' header to the request:, (*6)

$result = $magentoService->request('/api/rest/customers', 'GET', null, array('Accept' => '*/*'));

The Versions

17/02 2014

dev-master

9999999-dev

Magento OAuth Test

  Sources   Download

MIT

The Requires

 

The Development Requires

17/02 2014

v1.0.1

1.0.1.0

Magento OAuth Test

  Sources   Download

MIT

The Requires

 

The Development Requires

17/02 2014

v1.0.0

1.0.0.0

Magento OAuth Test

  Sources   Download

MIT

The Requires

 

The Development Requires