Skip to content

Commit 4c9212b

Browse files
authored
Merge pull request #54 from BingAds/march-updates
Updated to support Microsoft Account authentication in sandbox
2 parents 0d7d5e8 + a50b804 commit 4c9212b

File tree

70 files changed

+658
-167
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+658
-167
lines changed

samples/AuthHelper.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ final class AuthHelper {
2929
const OAuthRefreshTokenPath = 'refresh.txt';
3030
const ClientId = 'ClientIdGoesHere';
3131
const ClientSecret = 'ClientSecretGoesHere';
32-
const RedirectUri = "https://login.live.com/oauth20_desktop.srf";
3332

3433
// Sets the global authorization data instance with PasswordAuthentication.
3534

@@ -49,8 +48,8 @@ static function AuthenticateWithUserName()
4948
static function AuthenticateWithOAuth()
5049
{
5150
$authentication = (new OAuthDesktopMobileAuthCodeGrant())
52-
->withClientId(AuthHelper::ClientId)
53-
->withRedirectUri(AuthHelper::RedirectUri);
51+
->withEnvironment(AuthHelper::ApiEnvironment)
52+
->withClientId(AuthHelper::ClientId);
5453

5554
$GLOBALS['AuthorizationData'] = (new AuthorizationData())
5655
->withAuthentication($authentication)

samples/V11/AdExtensions.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,14 @@
7171

7272
try
7373
{
74-
// You should authenticate for Bing Ads production services with a Microsoft Account,
74+
// You should authenticate for Bing Ads services with a Microsoft Account,
7575
// instead of providing the Bing Ads username and password set.
7676

77-
//AuthHelper::AuthenticateWithOAuth();
77+
AuthHelper::AuthenticateWithOAuth();
7878

79-
// However, authentication with a Microsoft Account is currently not supported in Sandbox,
80-
// so it is recommended that you set the UserName and Password in sandbox for testing.
81-
82-
AuthHelper::AuthenticateWithUserName();
79+
// Bing Ads API Version 11 is the last version to support UserName and Password authentication,
80+
// so this function is deprecated.
81+
//AuthHelper::AuthenticateWithUserName();
8382

8483
$GLOBALS['CustomerProxy'] = new ServiceClient(ServiceClientType::CustomerManagementVersion11, $GLOBALS['AuthorizationData'], AuthHelper::GetApiEnvironment());
8584

samples/V11/BudgetOpportunities.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,14 @@
3838

3939
try
4040
{
41-
// You should authenticate for Bing Ads production services with a Microsoft Account,
41+
// You should authenticate for Bing Ads services with a Microsoft Account,
4242
// instead of providing the Bing Ads username and password set.
4343

44-
//AuthHelper::AuthenticateWithOAuth();
44+
AuthHelper::AuthenticateWithOAuth();
4545

46-
// However, authentication with a Microsoft Account is currently not supported in Sandbox,
47-
// so it is recommended that you set the UserName and Password in sandbox for testing.
48-
49-
AuthHelper::AuthenticateWithUserName();
46+
// Bing Ads API Version 11 is the last version to support UserName and Password authentication,
47+
// so this function is deprecated.
48+
//AuthHelper::AuthenticateWithUserName();
5049

5150
$GLOBALS['CustomerProxy'] = new ServiceClient(ServiceClientType::CustomerManagementVersion11, $GLOBALS['AuthorizationData'], AuthHelper::GetApiEnvironment());
5251

samples/V11/BulkDownloadUpload.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,14 @@
8282

8383
try
8484
{
85-
// You should authenticate for Bing Ads production services with a Microsoft Account,
85+
// You should authenticate for Bing Ads services with a Microsoft Account,
8686
// instead of providing the Bing Ads username and password set.
8787

88-
//AuthHelper::AuthenticateWithOAuth();
88+
AuthHelper::AuthenticateWithOAuth();
8989

90-
// However, authentication with a Microsoft Account is currently not supported in Sandbox,
91-
// so it is recommended that you set the UserName and Password in sandbox for testing.
92-
93-
AuthHelper::AuthenticateWithUserName();
90+
// Bing Ads API Version 11 is the last version to support UserName and Password authentication,
91+
// so this function is deprecated.
92+
//AuthHelper::AuthenticateWithUserName();
9493

9594
$GLOBALS['CustomerProxy'] = new ServiceClient(ServiceClientType::CustomerManagementVersion11, $GLOBALS['AuthorizationData'], AuthHelper::GetApiEnvironment());
9695

samples/V11/ConversionGoals.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,14 @@
5353

5454
try
5555
{
56-
// You should authenticate for Bing Ads production services with a Microsoft Account,
56+
// You should authenticate for Bing Ads services with a Microsoft Account,
5757
// instead of providing the Bing Ads username and password set.
5858

59-
//AuthHelper::AuthenticateWithOAuth();
59+
AuthHelper::AuthenticateWithOAuth();
6060

61-
// However, authentication with a Microsoft Account is currently not supported in Sandbox,
62-
// so it is recommended that you set the UserName and Password in sandbox for testing.
63-
64-
AuthHelper::AuthenticateWithUserName();
61+
// Bing Ads API Version 11 is the last version to support UserName and Password authentication,
62+
// so this function is deprecated.
63+
//AuthHelper::AuthenticateWithUserName();
6564

6665
$GLOBALS['CustomerProxy'] = new ServiceClient(ServiceClientType::CustomerManagementVersion11, $GLOBALS['AuthorizationData'], AuthHelper::GetApiEnvironment());
6766

samples/V11/CustomerSignup.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,14 @@
4545

4646
try
4747
{
48-
// You should authenticate for Bing Ads production services with a Microsoft Account,
48+
// You should authenticate for Bing Ads services with a Microsoft Account,
4949
// instead of providing the Bing Ads username and password set.
5050

51-
//AuthHelper::AuthenticateWithOAuth();
51+
AuthHelper::AuthenticateWithOAuth();
5252

53-
// However, authentication with a Microsoft Account is currently not supported in Sandbox,
54-
// so it is recommended that you set the UserName and Password in sandbox for testing.
55-
56-
AuthHelper::AuthenticateWithUserName();
53+
// Bing Ads API Version 11 is the last version to support UserName and Password authentication,
54+
// so this function is deprecated.
55+
//AuthHelper::AuthenticateWithUserName();
5756

5857
$GLOBALS['CustomerProxy'] = new ServiceClient(ServiceClientType::CustomerManagementVersion11, $GLOBALS['AuthorizationData'], AuthHelper::GetApiEnvironment());
5958

samples/V11/DynamicSearchAds.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,14 @@
7171

7272
try
7373
{
74-
// You should authenticate for Bing Ads production services with a Microsoft Account,
74+
// You should authenticate for Bing Ads services with a Microsoft Account,
7575
// instead of providing the Bing Ads username and password set.
7676

77-
//AuthHelper::AuthenticateWithOAuth();
77+
AuthHelper::AuthenticateWithOAuth();
7878

79-
// However, authentication with a Microsoft Account is currently not supported in Sandbox,
80-
// so it is recommended that you set the UserName and Password in sandbox for testing.
81-
82-
AuthHelper::AuthenticateWithUserName();
79+
// Bing Ads API Version 11 is the last version to support UserName and Password authentication,
80+
// so this function is deprecated.
81+
//AuthHelper::AuthenticateWithUserName();
8382

8483
$GLOBALS['CustomerProxy'] = new ServiceClient(ServiceClientType::CustomerManagementVersion11, $GLOBALS['AuthorizationData'], AuthHelper::GetApiEnvironment());
8584

samples/V11/GeographicalLocations.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,14 @@
5555

5656
try
5757
{
58-
// You should authenticate for Bing Ads production services with a Microsoft Account,
58+
// You should authenticate for Bing Ads services with a Microsoft Account,
5959
// instead of providing the Bing Ads username and password set.
6060

61-
//AuthHelper::AuthenticateWithOAuth();
61+
AuthHelper::AuthenticateWithOAuth();
6262

63-
// However, authentication with a Microsoft Account is currently not supported in Sandbox,
64-
// so it is recommended that you set the UserName and Password in sandbox for testing.
65-
66-
AuthHelper::AuthenticateWithUserName();
63+
// Bing Ads API Version 11 is the last version to support UserName and Password authentication,
64+
// so this function is deprecated.
65+
//AuthHelper::AuthenticateWithUserName();
6766

6867
$GLOBALS['CustomerProxy'] = new ServiceClient(ServiceClientType::CustomerManagementVersion11, $GLOBALS['AuthorizationData'], AuthHelper::GetApiEnvironment());
6968

samples/V11/KeywordPlanner.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,14 @@
7373

7474
try
7575
{
76-
// You should authenticate for Bing Ads production services with a Microsoft Account,
76+
// You should authenticate for Bing Ads services with a Microsoft Account,
7777
// instead of providing the Bing Ads username and password set.
7878

79-
//AuthHelper::AuthenticateWithOAuth();
79+
AuthHelper::AuthenticateWithOAuth();
8080

81-
// However, authentication with a Microsoft Account is currently not supported in Sandbox,
82-
// so it is recommended that you set the UserName and Password in sandbox for testing.
83-
84-
AuthHelper::AuthenticateWithUserName();
81+
// Bing Ads API Version 11 is the last version to support UserName and Password authentication,
82+
// so this function is deprecated.
83+
//AuthHelper::AuthenticateWithUserName();
8584

8685
$GLOBALS['CustomerProxy'] = new ServiceClient(ServiceClientType::CustomerManagementVersion11, $GLOBALS['AuthorizationData'], AuthHelper::GetApiEnvironment());
8786

samples/V11/KeywordsAds.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,14 @@
6060

6161
try
6262
{
63-
// You should authenticate for Bing Ads production services with a Microsoft Account,
63+
// You should authenticate for Bing Ads services with a Microsoft Account,
6464
// instead of providing the Bing Ads username and password set.
6565

66-
//AuthHelper::AuthenticateWithOAuth();
66+
AuthHelper::AuthenticateWithOAuth();
6767

68-
// However, authentication with a Microsoft Account is currently not supported in Sandbox,
69-
// so it is recommended that you set the UserName and Password in sandbox for testing.
70-
71-
AuthHelper::AuthenticateWithUserName();
68+
// Bing Ads API Version 11 is the last version to support UserName and Password authentication,
69+
// so this function is deprecated.
70+
//AuthHelper::AuthenticateWithUserName();
7271

7372
$GLOBALS['CustomerProxy'] = new ServiceClient(ServiceClientType::CustomerManagementVersion11, $GLOBALS['AuthorizationData'], AuthHelper::GetApiEnvironment());
7473

0 commit comments

Comments
 (0)