Skip to content

Commit

Permalink
Merge pull request #54 from BingAds/march-updates
Browse files Browse the repository at this point in the history
Updated to support Microsoft Account authentication in sandbox
  • Loading branch information
eric-urban authored Mar 13, 2018
2 parents 0d7d5e8 + a50b804 commit 4c9212b
Show file tree
Hide file tree
Showing 70 changed files with 658 additions and 167 deletions.
5 changes: 2 additions & 3 deletions samples/AuthHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ final class AuthHelper {
const OAuthRefreshTokenPath = 'refresh.txt';
const ClientId = 'ClientIdGoesHere';
const ClientSecret = 'ClientSecretGoesHere';
const RedirectUri = "https://login.live.com/oauth20_desktop.srf";

// Sets the global authorization data instance with PasswordAuthentication.

Expand All @@ -49,8 +48,8 @@ static function AuthenticateWithUserName()
static function AuthenticateWithOAuth()
{
$authentication = (new OAuthDesktopMobileAuthCodeGrant())
->withClientId(AuthHelper::ClientId)
->withRedirectUri(AuthHelper::RedirectUri);
->withEnvironment(AuthHelper::ApiEnvironment)
->withClientId(AuthHelper::ClientId);

$GLOBALS['AuthorizationData'] = (new AuthorizationData())
->withAuthentication($authentication)
Expand Down
11 changes: 5 additions & 6 deletions samples/V11/AdExtensions.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,14 @@

try
{
// You should authenticate for Bing Ads production services with a Microsoft Account,
// You should authenticate for Bing Ads services with a Microsoft Account,
// instead of providing the Bing Ads username and password set.

//AuthHelper::AuthenticateWithOAuth();
AuthHelper::AuthenticateWithOAuth();

// However, authentication with a Microsoft Account is currently not supported in Sandbox,
// so it is recommended that you set the UserName and Password in sandbox for testing.

AuthHelper::AuthenticateWithUserName();
// Bing Ads API Version 11 is the last version to support UserName and Password authentication,
// so this function is deprecated.
//AuthHelper::AuthenticateWithUserName();

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

Expand Down
11 changes: 5 additions & 6 deletions samples/V11/BudgetOpportunities.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,14 @@

try
{
// You should authenticate for Bing Ads production services with a Microsoft Account,
// You should authenticate for Bing Ads services with a Microsoft Account,
// instead of providing the Bing Ads username and password set.

//AuthHelper::AuthenticateWithOAuth();
AuthHelper::AuthenticateWithOAuth();

// However, authentication with a Microsoft Account is currently not supported in Sandbox,
// so it is recommended that you set the UserName and Password in sandbox for testing.

AuthHelper::AuthenticateWithUserName();
// Bing Ads API Version 11 is the last version to support UserName and Password authentication,
// so this function is deprecated.
//AuthHelper::AuthenticateWithUserName();

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

Expand Down
11 changes: 5 additions & 6 deletions samples/V11/BulkDownloadUpload.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,14 @@

try
{
// You should authenticate for Bing Ads production services with a Microsoft Account,
// You should authenticate for Bing Ads services with a Microsoft Account,
// instead of providing the Bing Ads username and password set.

//AuthHelper::AuthenticateWithOAuth();
AuthHelper::AuthenticateWithOAuth();

// However, authentication with a Microsoft Account is currently not supported in Sandbox,
// so it is recommended that you set the UserName and Password in sandbox for testing.

AuthHelper::AuthenticateWithUserName();
// Bing Ads API Version 11 is the last version to support UserName and Password authentication,
// so this function is deprecated.
//AuthHelper::AuthenticateWithUserName();

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

Expand Down
11 changes: 5 additions & 6 deletions samples/V11/ConversionGoals.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,14 @@

try
{
// You should authenticate for Bing Ads production services with a Microsoft Account,
// You should authenticate for Bing Ads services with a Microsoft Account,
// instead of providing the Bing Ads username and password set.

//AuthHelper::AuthenticateWithOAuth();
AuthHelper::AuthenticateWithOAuth();

// However, authentication with a Microsoft Account is currently not supported in Sandbox,
// so it is recommended that you set the UserName and Password in sandbox for testing.

AuthHelper::AuthenticateWithUserName();
// Bing Ads API Version 11 is the last version to support UserName and Password authentication,
// so this function is deprecated.
//AuthHelper::AuthenticateWithUserName();

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

Expand Down
11 changes: 5 additions & 6 deletions samples/V11/CustomerSignup.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,14 @@

try
{
// You should authenticate for Bing Ads production services with a Microsoft Account,
// You should authenticate for Bing Ads services with a Microsoft Account,
// instead of providing the Bing Ads username and password set.

//AuthHelper::AuthenticateWithOAuth();
AuthHelper::AuthenticateWithOAuth();

// However, authentication with a Microsoft Account is currently not supported in Sandbox,
// so it is recommended that you set the UserName and Password in sandbox for testing.

AuthHelper::AuthenticateWithUserName();
// Bing Ads API Version 11 is the last version to support UserName and Password authentication,
// so this function is deprecated.
//AuthHelper::AuthenticateWithUserName();

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

Expand Down
11 changes: 5 additions & 6 deletions samples/V11/DynamicSearchAds.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,14 @@

try
{
// You should authenticate for Bing Ads production services with a Microsoft Account,
// You should authenticate for Bing Ads services with a Microsoft Account,
// instead of providing the Bing Ads username and password set.

//AuthHelper::AuthenticateWithOAuth();
AuthHelper::AuthenticateWithOAuth();

// However, authentication with a Microsoft Account is currently not supported in Sandbox,
// so it is recommended that you set the UserName and Password in sandbox for testing.

AuthHelper::AuthenticateWithUserName();
// Bing Ads API Version 11 is the last version to support UserName and Password authentication,
// so this function is deprecated.
//AuthHelper::AuthenticateWithUserName();

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

Expand Down
11 changes: 5 additions & 6 deletions samples/V11/GeographicalLocations.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,14 @@

try
{
// You should authenticate for Bing Ads production services with a Microsoft Account,
// You should authenticate for Bing Ads services with a Microsoft Account,
// instead of providing the Bing Ads username and password set.

//AuthHelper::AuthenticateWithOAuth();
AuthHelper::AuthenticateWithOAuth();

// However, authentication with a Microsoft Account is currently not supported in Sandbox,
// so it is recommended that you set the UserName and Password in sandbox for testing.

AuthHelper::AuthenticateWithUserName();
// Bing Ads API Version 11 is the last version to support UserName and Password authentication,
// so this function is deprecated.
//AuthHelper::AuthenticateWithUserName();

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

Expand Down
11 changes: 5 additions & 6 deletions samples/V11/KeywordPlanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,14 @@

try
{
// You should authenticate for Bing Ads production services with a Microsoft Account,
// You should authenticate for Bing Ads services with a Microsoft Account,
// instead of providing the Bing Ads username and password set.

//AuthHelper::AuthenticateWithOAuth();
AuthHelper::AuthenticateWithOAuth();

// However, authentication with a Microsoft Account is currently not supported in Sandbox,
// so it is recommended that you set the UserName and Password in sandbox for testing.

AuthHelper::AuthenticateWithUserName();
// Bing Ads API Version 11 is the last version to support UserName and Password authentication,
// so this function is deprecated.
//AuthHelper::AuthenticateWithUserName();

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

Expand Down
11 changes: 5 additions & 6 deletions samples/V11/KeywordsAds.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,14 @@

try
{
// You should authenticate for Bing Ads production services with a Microsoft Account,
// You should authenticate for Bing Ads services with a Microsoft Account,
// instead of providing the Bing Ads username and password set.

//AuthHelper::AuthenticateWithOAuth();
AuthHelper::AuthenticateWithOAuth();

// However, authentication with a Microsoft Account is currently not supported in Sandbox,
// so it is recommended that you set the UserName and Password in sandbox for testing.

AuthHelper::AuthenticateWithUserName();
// Bing Ads API Version 11 is the last version to support UserName and Password authentication,
// so this function is deprecated.
//AuthHelper::AuthenticateWithUserName();

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

Expand Down
11 changes: 5 additions & 6 deletions samples/V11/ManageClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,14 @@

try
{
// You should authenticate for Bing Ads production services with a Microsoft Account,
// You should authenticate for Bing Ads services with a Microsoft Account,
// instead of providing the Bing Ads username and password set.

//AuthHelper::AuthenticateWithOAuth();
AuthHelper::AuthenticateWithOAuth();

// However, authentication with a Microsoft Account is currently not supported in Sandbox,
// so it is recommended that you set the UserName and Password in sandbox for testing.

AuthHelper::AuthenticateWithUserName();
// Bing Ads API Version 11 is the last version to support UserName and Password authentication,
// so this function is deprecated.
//AuthHelper::AuthenticateWithUserName();

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

Expand Down
11 changes: 5 additions & 6 deletions samples/V11/NegativeKeywords.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,14 @@

try
{
// You should authenticate for Bing Ads production services with a Microsoft Account,
// You should authenticate for Bing Ads services with a Microsoft Account,
// instead of providing the Bing Ads username and password set.

//AuthHelper::AuthenticateWithOAuth();
AuthHelper::AuthenticateWithOAuth();

// However, authentication with a Microsoft Account is currently not supported in Sandbox,
// so it is recommended that you set the UserName and Password in sandbox for testing.

AuthHelper::AuthenticateWithUserName();
// Bing Ads API Version 11 is the last version to support UserName and Password authentication,
// so this function is deprecated.
//AuthHelper::AuthenticateWithUserName();

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

Expand Down
11 changes: 5 additions & 6 deletions samples/V11/RemarketingLists.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,14 @@

try
{
// You should authenticate for Bing Ads production services with a Microsoft Account,
// You should authenticate for Bing Ads services with a Microsoft Account,
// instead of providing the Bing Ads username and password set.

//AuthHelper::AuthenticateWithOAuth();
AuthHelper::AuthenticateWithOAuth();

// However, authentication with a Microsoft Account is currently not supported in Sandbox,
// so it is recommended that you set the UserName and Password in sandbox for testing.

AuthHelper::AuthenticateWithUserName();
// Bing Ads API Version 11 is the last version to support UserName and Password authentication,
// so this function is deprecated.
//AuthHelper::AuthenticateWithUserName();

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

Expand Down
11 changes: 5 additions & 6 deletions samples/V11/ReportRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,14 @@

try
{
// You should authenticate for Bing Ads production services with a Microsoft Account,
// You should authenticate for Bing Ads services with a Microsoft Account,
// instead of providing the Bing Ads username and password set.

//AuthHelper::AuthenticateWithOAuth();
AuthHelper::AuthenticateWithOAuth();

// However, authentication with a Microsoft Account is currently not supported in Sandbox,
// so it is recommended that you set the UserName and Password in sandbox for testing.

AuthHelper::AuthenticateWithUserName();
// Bing Ads API Version 11 is the last version to support UserName and Password authentication,
// so this function is deprecated.
//AuthHelper::AuthenticateWithUserName();

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

Expand Down
11 changes: 5 additions & 6 deletions samples/V11/SearchUserAccounts.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,14 @@

try
{
// You should authenticate for Bing Ads production services with a Microsoft Account,
// You should authenticate for Bing Ads services with a Microsoft Account,
// instead of providing the Bing Ads username and password set.

//AuthHelper::AuthenticateWithOAuth();
AuthHelper::AuthenticateWithOAuth();

// However, authentication with a Microsoft Account is currently not supported in Sandbox,
// so it is recommended that you set the UserName and Password in sandbox for testing.

AuthHelper::AuthenticateWithUserName();
// Bing Ads API Version 11 is the last version to support UserName and Password authentication,
// so this function is deprecated.
//AuthHelper::AuthenticateWithUserName();

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

Expand Down
11 changes: 5 additions & 6 deletions samples/V11/ShoppingCampaigns.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,14 @@

try
{
// You should authenticate for Bing Ads production services with a Microsoft Account,
// You should authenticate for Bing Ads services with a Microsoft Account,
// instead of providing the Bing Ads username and password set.

//AuthHelper::AuthenticateWithOAuth();
AuthHelper::AuthenticateWithOAuth();

// However, authentication with a Microsoft Account is currently not supported in Sandbox,
// so it is recommended that you set the UserName and Password in sandbox for testing.

AuthHelper::AuthenticateWithUserName();
// Bing Ads API Version 11 is the last version to support UserName and Password authentication,
// so this function is deprecated.
//AuthHelper::AuthenticateWithUserName();

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

Expand Down
11 changes: 5 additions & 6 deletions samples/V11/TargetCriterions.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,14 @@

try
{
// You should authenticate for Bing Ads production services with a Microsoft Account,
// You should authenticate for Bing Ads services with a Microsoft Account,
// instead of providing the Bing Ads username and password set.

//AuthHelper::AuthenticateWithOAuth();
AuthHelper::AuthenticateWithOAuth();

// However, authentication with a Microsoft Account is currently not supported in Sandbox,
// so it is recommended that you set the UserName and Password in sandbox for testing.

AuthHelper::AuthenticateWithUserName();
// Bing Ads API Version 11 is the last version to support UserName and Password authentication,
// so this function is deprecated.
//AuthHelper::AuthenticateWithUserName();

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

Expand Down
2 changes: 1 addition & 1 deletion src/Auth/HttpService.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
class HttpService
{
public function post($url, $postData) {
public function post($url, $postData) {
$ch = curl_init();

$query = "";
Expand Down
5 changes: 4 additions & 1 deletion src/Auth/IOAuthService.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@ abstract class IOAuthService
* Implementations of this abstract method must call the authorization server with the oauthRequestParameters passed in,
* deserialize the response, and return back OAuth tokens.
*/
abstract function GetAccessTokens(OAuthRequestParameters $oauthParameters);
abstract function GetAccessTokens(OAuthRequestParameters $oauthParameters, $environment);

abstract static function getRedirectUrl($environment);

}
Loading

0 comments on commit 4c9212b

Please sign in to comment.