Example #1
0
 public function testGetAuthorizationUrl()
 {
     $client = new Client('AccessToken', 'SecretKey');
     $client->setShop('example.myshopify.com')->addScope(Client::SCOPE_READ_CUSTOMERS);
     $actual = $client->getAuthorizationUrl('https://example.com', 1);
     $expected = 'https://example.myshopify.com/admin/oauth/authorize?client_id=AccessToken&scope=read_customers&redirect_uri=https%3A%2F%2Fexample.com&state=1';
     $this->assertSame($expected, $actual);
 }
 public function indexAction(Request $request)
 {
     $hmac = $request->query->get('hmac');
     $shop = $request->query->get('shop');
     $signature = $request->query->get('signature');
     $timestamp = $request->query->get('timestamp');
     $this->get('session')->set('shop', $shop);
     $key = $this->getParameter('shopify.key');
     $secret = $this->getParameter('shopify.secret');
     $client = new Client($key, $secret);
     $client->setShop($shop);
     $client->setScopes('read_products,read_customers,read_orders');
     $authUrl = $client->getAuthorizationUrl($this->generateUrl('dspace_shopify_auth_callback', array(), UrlGeneratorInterface::ABSOLUTE_URL));
     var_dump($request->query->all(), $request->getMethod(), $authUrl);
     die;
     return $this->redirect($authUrl);
 }