Bing Ads sdk V12: Error code 105, Invalid Credential (Customer Management)












0















I have a problem about the error code 105 (Message: "Authentication failed. Either supplied credentials are invalid or the account is inactive") when performing a "GetUser" request. I've already understand that it's because of an incorrect access token (AuthenticationToken header element) or developer token for the target environment. So it must be about the way I set my credentials (or my credentials). Here is my code:



public function getAuthorization()
{
$result = AuthController::getRefreshToken(); //get The refresh token, update it if necessary
AuthController::WriteOAuthRefreshToken($result); //stock the refresh token

$authentication = (new OAuthWebAuthCodeGrant())
->withEnvironment(AuthController::ApiEnvironment) //production
->withClientSecret(AuthController::ClientSecret)
->withClientId(AuthController::ClientId)
->withOAuthTokens(
(new OAuthTokens())
->withAccessToken(json_decode($result, true)["access_token"])
->withRefreshToken(json_decode($result, true)["refresh_token"])
->withAccessTokenExpiresInSeconds(3600))
->withRedirectUri(AuthController::RedirectUri)
->withState(rand(0,999999999));

$GLOBALS['AuthorizationData'] = (new AuthorizationData())
->withAuthentication($authentication)
->withDeveloperToken(AuthController::DeveloperToken);

AuthController::Authenticate();
}


And here is the function to Authenticate which call the getUser Function ()



static function Authenticate()
{
// Authenticate for Bing Ads services with a Microsoft Account. Perform a $GLOBALS['AuthorizationData']->Authentication->RequestOAuthTokensByRefreshToken($refreshToken);
AuthController::AuthenticateWithOAuth();

$GLOBALS['CustomerManagementProxy'] = new ServiceClient(
ServiceClientType::CustomerManagementVersion12,
$GLOBALS['AuthorizationData'],
AuthController::ApiEnvironment);
$GLOBALS['CustomerManagementProxy']->SetAuthorizationData($GLOBALS['AuthorizationData']);

// Here is the problem
$user = AuthController::GetUser(null, true)->User;
}


The getUser function I currently use is the same as the one in the php "Code Syntax" part in the documentation.
I'm using the production environment with my own credentials. I've already checked my developer token and all the correspondant rights (wich seems correct). I update my tokens each time I'm trying to do that request.
Is there any problems about the way i set the request?
If the problem is about the tokens, is there a way to check if it's correct?
I precise I've tried also with the getAccount function with the same result.



Any ideas? Thanks for your time.










share|improve this question



























    0















    I have a problem about the error code 105 (Message: "Authentication failed. Either supplied credentials are invalid or the account is inactive") when performing a "GetUser" request. I've already understand that it's because of an incorrect access token (AuthenticationToken header element) or developer token for the target environment. So it must be about the way I set my credentials (or my credentials). Here is my code:



    public function getAuthorization()
    {
    $result = AuthController::getRefreshToken(); //get The refresh token, update it if necessary
    AuthController::WriteOAuthRefreshToken($result); //stock the refresh token

    $authentication = (new OAuthWebAuthCodeGrant())
    ->withEnvironment(AuthController::ApiEnvironment) //production
    ->withClientSecret(AuthController::ClientSecret)
    ->withClientId(AuthController::ClientId)
    ->withOAuthTokens(
    (new OAuthTokens())
    ->withAccessToken(json_decode($result, true)["access_token"])
    ->withRefreshToken(json_decode($result, true)["refresh_token"])
    ->withAccessTokenExpiresInSeconds(3600))
    ->withRedirectUri(AuthController::RedirectUri)
    ->withState(rand(0,999999999));

    $GLOBALS['AuthorizationData'] = (new AuthorizationData())
    ->withAuthentication($authentication)
    ->withDeveloperToken(AuthController::DeveloperToken);

    AuthController::Authenticate();
    }


    And here is the function to Authenticate which call the getUser Function ()



    static function Authenticate()
    {
    // Authenticate for Bing Ads services with a Microsoft Account. Perform a $GLOBALS['AuthorizationData']->Authentication->RequestOAuthTokensByRefreshToken($refreshToken);
    AuthController::AuthenticateWithOAuth();

    $GLOBALS['CustomerManagementProxy'] = new ServiceClient(
    ServiceClientType::CustomerManagementVersion12,
    $GLOBALS['AuthorizationData'],
    AuthController::ApiEnvironment);
    $GLOBALS['CustomerManagementProxy']->SetAuthorizationData($GLOBALS['AuthorizationData']);

    // Here is the problem
    $user = AuthController::GetUser(null, true)->User;
    }


    The getUser function I currently use is the same as the one in the php "Code Syntax" part in the documentation.
    I'm using the production environment with my own credentials. I've already checked my developer token and all the correspondant rights (wich seems correct). I update my tokens each time I'm trying to do that request.
    Is there any problems about the way i set the request?
    If the problem is about the tokens, is there a way to check if it's correct?
    I precise I've tried also with the getAccount function with the same result.



    Any ideas? Thanks for your time.










    share|improve this question

























      0












      0








      0








      I have a problem about the error code 105 (Message: "Authentication failed. Either supplied credentials are invalid or the account is inactive") when performing a "GetUser" request. I've already understand that it's because of an incorrect access token (AuthenticationToken header element) or developer token for the target environment. So it must be about the way I set my credentials (or my credentials). Here is my code:



      public function getAuthorization()
      {
      $result = AuthController::getRefreshToken(); //get The refresh token, update it if necessary
      AuthController::WriteOAuthRefreshToken($result); //stock the refresh token

      $authentication = (new OAuthWebAuthCodeGrant())
      ->withEnvironment(AuthController::ApiEnvironment) //production
      ->withClientSecret(AuthController::ClientSecret)
      ->withClientId(AuthController::ClientId)
      ->withOAuthTokens(
      (new OAuthTokens())
      ->withAccessToken(json_decode($result, true)["access_token"])
      ->withRefreshToken(json_decode($result, true)["refresh_token"])
      ->withAccessTokenExpiresInSeconds(3600))
      ->withRedirectUri(AuthController::RedirectUri)
      ->withState(rand(0,999999999));

      $GLOBALS['AuthorizationData'] = (new AuthorizationData())
      ->withAuthentication($authentication)
      ->withDeveloperToken(AuthController::DeveloperToken);

      AuthController::Authenticate();
      }


      And here is the function to Authenticate which call the getUser Function ()



      static function Authenticate()
      {
      // Authenticate for Bing Ads services with a Microsoft Account. Perform a $GLOBALS['AuthorizationData']->Authentication->RequestOAuthTokensByRefreshToken($refreshToken);
      AuthController::AuthenticateWithOAuth();

      $GLOBALS['CustomerManagementProxy'] = new ServiceClient(
      ServiceClientType::CustomerManagementVersion12,
      $GLOBALS['AuthorizationData'],
      AuthController::ApiEnvironment);
      $GLOBALS['CustomerManagementProxy']->SetAuthorizationData($GLOBALS['AuthorizationData']);

      // Here is the problem
      $user = AuthController::GetUser(null, true)->User;
      }


      The getUser function I currently use is the same as the one in the php "Code Syntax" part in the documentation.
      I'm using the production environment with my own credentials. I've already checked my developer token and all the correspondant rights (wich seems correct). I update my tokens each time I'm trying to do that request.
      Is there any problems about the way i set the request?
      If the problem is about the tokens, is there a way to check if it's correct?
      I precise I've tried also with the getAccount function with the same result.



      Any ideas? Thanks for your time.










      share|improve this question














      I have a problem about the error code 105 (Message: "Authentication failed. Either supplied credentials are invalid or the account is inactive") when performing a "GetUser" request. I've already understand that it's because of an incorrect access token (AuthenticationToken header element) or developer token for the target environment. So it must be about the way I set my credentials (or my credentials). Here is my code:



      public function getAuthorization()
      {
      $result = AuthController::getRefreshToken(); //get The refresh token, update it if necessary
      AuthController::WriteOAuthRefreshToken($result); //stock the refresh token

      $authentication = (new OAuthWebAuthCodeGrant())
      ->withEnvironment(AuthController::ApiEnvironment) //production
      ->withClientSecret(AuthController::ClientSecret)
      ->withClientId(AuthController::ClientId)
      ->withOAuthTokens(
      (new OAuthTokens())
      ->withAccessToken(json_decode($result, true)["access_token"])
      ->withRefreshToken(json_decode($result, true)["refresh_token"])
      ->withAccessTokenExpiresInSeconds(3600))
      ->withRedirectUri(AuthController::RedirectUri)
      ->withState(rand(0,999999999));

      $GLOBALS['AuthorizationData'] = (new AuthorizationData())
      ->withAuthentication($authentication)
      ->withDeveloperToken(AuthController::DeveloperToken);

      AuthController::Authenticate();
      }


      And here is the function to Authenticate which call the getUser Function ()



      static function Authenticate()
      {
      // Authenticate for Bing Ads services with a Microsoft Account. Perform a $GLOBALS['AuthorizationData']->Authentication->RequestOAuthTokensByRefreshToken($refreshToken);
      AuthController::AuthenticateWithOAuth();

      $GLOBALS['CustomerManagementProxy'] = new ServiceClient(
      ServiceClientType::CustomerManagementVersion12,
      $GLOBALS['AuthorizationData'],
      AuthController::ApiEnvironment);
      $GLOBALS['CustomerManagementProxy']->SetAuthorizationData($GLOBALS['AuthorizationData']);

      // Here is the problem
      $user = AuthController::GetUser(null, true)->User;
      }


      The getUser function I currently use is the same as the one in the php "Code Syntax" part in the documentation.
      I'm using the production environment with my own credentials. I've already checked my developer token and all the correspondant rights (wich seems correct). I update my tokens each time I'm trying to do that request.
      Is there any problems about the way i set the request?
      If the problem is about the tokens, is there a way to check if it's correct?
      I precise I've tried also with the getAccount function with the same result.



      Any ideas? Thanks for your time.







      php bing-ads-api






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 16 '18 at 9:16









      MKB 06MKB 06

      235




      235
























          1 Answer
          1






          active

          oldest

          votes


















          1














          Here are a few ideas to explore:




          1. Can you login to the Bing Ads web application with these credentials i.e., does this user have access to a Bing Ads account?

          2. Is the OAuthTokens->AccessToken set or empty e.g., try var_dump($authentication).

          3. Try refreshing the token directly in the auth object e.g., see this sample.


          4. Log the SOAP request and response to see if AuthenticationToken was set in the GetUser call e.g., immediately after the GetUser call print the last request/response:



            print $GLOBALS['Proxy']->GetService()->__getLastRequest()."n";
            print $GLOBALS['Proxy']->GetService()->__getLastResponse()."n";



          Otherwise to confirm credentials you might want to contact Bing Ads support directly.



          I hope this helps!






          share|improve this answer
























          • Unfortunately, I've tried this 4 points without different final results: 1. Yes, and with sufficient rights. 2. The OAuthTokens->AccessToken is correctly set. 3. I've got the same response than usual. (Error Code 105). 4. AuthenticationToken is correctly set. I can confess I'm a bit confused now, I really don't know where the problem is.

            – MKB 06
            Nov 22 '18 at 9:26











          • It seems that the problem was indeed my account. I don't know why, but even if i'm able to connect correctly to the web application the api seems to refuse my credentials. The problem disappears with another account. Thanks for the help!

            – MKB 06
            Nov 23 '18 at 9:22












          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53334722%2fbing-ads-sdk-v12-error-code-105-invalid-credential-customer-management%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          Here are a few ideas to explore:




          1. Can you login to the Bing Ads web application with these credentials i.e., does this user have access to a Bing Ads account?

          2. Is the OAuthTokens->AccessToken set or empty e.g., try var_dump($authentication).

          3. Try refreshing the token directly in the auth object e.g., see this sample.


          4. Log the SOAP request and response to see if AuthenticationToken was set in the GetUser call e.g., immediately after the GetUser call print the last request/response:



            print $GLOBALS['Proxy']->GetService()->__getLastRequest()."n";
            print $GLOBALS['Proxy']->GetService()->__getLastResponse()."n";



          Otherwise to confirm credentials you might want to contact Bing Ads support directly.



          I hope this helps!






          share|improve this answer
























          • Unfortunately, I've tried this 4 points without different final results: 1. Yes, and with sufficient rights. 2. The OAuthTokens->AccessToken is correctly set. 3. I've got the same response than usual. (Error Code 105). 4. AuthenticationToken is correctly set. I can confess I'm a bit confused now, I really don't know where the problem is.

            – MKB 06
            Nov 22 '18 at 9:26











          • It seems that the problem was indeed my account. I don't know why, but even if i'm able to connect correctly to the web application the api seems to refuse my credentials. The problem disappears with another account. Thanks for the help!

            – MKB 06
            Nov 23 '18 at 9:22
















          1














          Here are a few ideas to explore:




          1. Can you login to the Bing Ads web application with these credentials i.e., does this user have access to a Bing Ads account?

          2. Is the OAuthTokens->AccessToken set or empty e.g., try var_dump($authentication).

          3. Try refreshing the token directly in the auth object e.g., see this sample.


          4. Log the SOAP request and response to see if AuthenticationToken was set in the GetUser call e.g., immediately after the GetUser call print the last request/response:



            print $GLOBALS['Proxy']->GetService()->__getLastRequest()."n";
            print $GLOBALS['Proxy']->GetService()->__getLastResponse()."n";



          Otherwise to confirm credentials you might want to contact Bing Ads support directly.



          I hope this helps!






          share|improve this answer
























          • Unfortunately, I've tried this 4 points without different final results: 1. Yes, and with sufficient rights. 2. The OAuthTokens->AccessToken is correctly set. 3. I've got the same response than usual. (Error Code 105). 4. AuthenticationToken is correctly set. I can confess I'm a bit confused now, I really don't know where the problem is.

            – MKB 06
            Nov 22 '18 at 9:26











          • It seems that the problem was indeed my account. I don't know why, but even if i'm able to connect correctly to the web application the api seems to refuse my credentials. The problem disappears with another account. Thanks for the help!

            – MKB 06
            Nov 23 '18 at 9:22














          1












          1








          1







          Here are a few ideas to explore:




          1. Can you login to the Bing Ads web application with these credentials i.e., does this user have access to a Bing Ads account?

          2. Is the OAuthTokens->AccessToken set or empty e.g., try var_dump($authentication).

          3. Try refreshing the token directly in the auth object e.g., see this sample.


          4. Log the SOAP request and response to see if AuthenticationToken was set in the GetUser call e.g., immediately after the GetUser call print the last request/response:



            print $GLOBALS['Proxy']->GetService()->__getLastRequest()."n";
            print $GLOBALS['Proxy']->GetService()->__getLastResponse()."n";



          Otherwise to confirm credentials you might want to contact Bing Ads support directly.



          I hope this helps!






          share|improve this answer













          Here are a few ideas to explore:




          1. Can you login to the Bing Ads web application with these credentials i.e., does this user have access to a Bing Ads account?

          2. Is the OAuthTokens->AccessToken set or empty e.g., try var_dump($authentication).

          3. Try refreshing the token directly in the auth object e.g., see this sample.


          4. Log the SOAP request and response to see if AuthenticationToken was set in the GetUser call e.g., immediately after the GetUser call print the last request/response:



            print $GLOBALS['Proxy']->GetService()->__getLastRequest()."n";
            print $GLOBALS['Proxy']->GetService()->__getLastResponse()."n";



          Otherwise to confirm credentials you might want to contact Bing Ads support directly.



          I hope this helps!







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 16 '18 at 17:41









          Eric UrbanEric Urban

          2005




          2005













          • Unfortunately, I've tried this 4 points without different final results: 1. Yes, and with sufficient rights. 2. The OAuthTokens->AccessToken is correctly set. 3. I've got the same response than usual. (Error Code 105). 4. AuthenticationToken is correctly set. I can confess I'm a bit confused now, I really don't know where the problem is.

            – MKB 06
            Nov 22 '18 at 9:26











          • It seems that the problem was indeed my account. I don't know why, but even if i'm able to connect correctly to the web application the api seems to refuse my credentials. The problem disappears with another account. Thanks for the help!

            – MKB 06
            Nov 23 '18 at 9:22



















          • Unfortunately, I've tried this 4 points without different final results: 1. Yes, and with sufficient rights. 2. The OAuthTokens->AccessToken is correctly set. 3. I've got the same response than usual. (Error Code 105). 4. AuthenticationToken is correctly set. I can confess I'm a bit confused now, I really don't know where the problem is.

            – MKB 06
            Nov 22 '18 at 9:26











          • It seems that the problem was indeed my account. I don't know why, but even if i'm able to connect correctly to the web application the api seems to refuse my credentials. The problem disappears with another account. Thanks for the help!

            – MKB 06
            Nov 23 '18 at 9:22

















          Unfortunately, I've tried this 4 points without different final results: 1. Yes, and with sufficient rights. 2. The OAuthTokens->AccessToken is correctly set. 3. I've got the same response than usual. (Error Code 105). 4. AuthenticationToken is correctly set. I can confess I'm a bit confused now, I really don't know where the problem is.

          – MKB 06
          Nov 22 '18 at 9:26





          Unfortunately, I've tried this 4 points without different final results: 1. Yes, and with sufficient rights. 2. The OAuthTokens->AccessToken is correctly set. 3. I've got the same response than usual. (Error Code 105). 4. AuthenticationToken is correctly set. I can confess I'm a bit confused now, I really don't know where the problem is.

          – MKB 06
          Nov 22 '18 at 9:26













          It seems that the problem was indeed my account. I don't know why, but even if i'm able to connect correctly to the web application the api seems to refuse my credentials. The problem disappears with another account. Thanks for the help!

          – MKB 06
          Nov 23 '18 at 9:22





          It seems that the problem was indeed my account. I don't know why, but even if i'm able to connect correctly to the web application the api seems to refuse my credentials. The problem disappears with another account. Thanks for the help!

          – MKB 06
          Nov 23 '18 at 9:22




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53334722%2fbing-ads-sdk-v12-error-code-105-invalid-credential-customer-management%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          List item for chat from Array inside array React Native

          Thiostrepton

          Caerphilly