Bing Ads sdk V12: Error code 105, Invalid Credential (Customer Management)
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
add a comment |
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
add a comment |
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
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
php bing-ads-api
asked Nov 16 '18 at 9:16
MKB 06MKB 06
235
235
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Here are a few ideas to explore:
- Can you login to the Bing Ads web application with these credentials i.e., does this user have access to a Bing Ads account?
- Is the OAuthTokens->AccessToken set or empty e.g., try var_dump($authentication).
- Try refreshing the token directly in the auth object e.g., see this sample.
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!
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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Here are a few ideas to explore:
- Can you login to the Bing Ads web application with these credentials i.e., does this user have access to a Bing Ads account?
- Is the OAuthTokens->AccessToken set or empty e.g., try var_dump($authentication).
- Try refreshing the token directly in the auth object e.g., see this sample.
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!
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
add a comment |
Here are a few ideas to explore:
- Can you login to the Bing Ads web application with these credentials i.e., does this user have access to a Bing Ads account?
- Is the OAuthTokens->AccessToken set or empty e.g., try var_dump($authentication).
- Try refreshing the token directly in the auth object e.g., see this sample.
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!
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
add a comment |
Here are a few ideas to explore:
- Can you login to the Bing Ads web application with these credentials i.e., does this user have access to a Bing Ads account?
- Is the OAuthTokens->AccessToken set or empty e.g., try var_dump($authentication).
- Try refreshing the token directly in the auth object e.g., see this sample.
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!
Here are a few ideas to explore:
- Can you login to the Bing Ads web application with these credentials i.e., does this user have access to a Bing Ads account?
- Is the OAuthTokens->AccessToken set or empty e.g., try var_dump($authentication).
- Try refreshing the token directly in the auth object e.g., see this sample.
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!
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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