Skip to content

Commit 7d1cf3c

Browse files
authored
Merge pull request #44 from felixlehmann/master
Added optional $redirect parameter to createAuthRequest() method
2 parents 5fcf8c5 + 2141fc8 commit 7d1cf3c

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

lib/AuthHelper.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,14 @@ public static function verifyShopifyRequest()
8080
*
8181
* @param string|string[] $scopes Scopes required by app
8282
* @param string $redirectUrl
83-
*
83+
* @param string $state
84+
* @param string[] $options
85+
* @param bool $redirect
8486
* @throws SdkException if required configuration is not provided in $config
8587
*
86-
* @return void
88+
* @return void|string
8789
*/
88-
public static function createAuthRequest($scopes, $redirectUrl = null, $state = null, $options = null)
90+
public static function createAuthRequest($scopes, $redirectUrl = null, $state = null, $options = null, $redirect = null)
8991
{
9092
$config = ShopifySDK::$config;
9193

@@ -119,6 +121,10 @@ public static function createAuthRequest($scopes, $redirectUrl = null, $state =
119121
// https://{shop}.myshopify.com/admin/oauth/authorize?client_id={api_key}&scope={scopes}&redirect_uri={redirect_uri}&state={nonce}&grant_options[]={option}
120122
$authUrl = $config['AdminUrl'] . 'oauth/authorize?client_id=' . $config['ApiKey'] . '&redirect_uri=' . $redirectUrl . "&scope=$scopes" . $state . $options;
121123

124+
if (!is_null($redirect)) {
125+
return $authUrl;
126+
}
127+
122128
header("Location: $authUrl");
123129
}
124130

0 commit comments

Comments
 (0)