MicrosoftDocs / Advertising-docs

Creative Commons Attribution 4.0 International
15 stars 59 forks source link

ClientSecret is not used in the code #368

Closed pentium10 closed 6 years ago

pentium10 commented 6 years ago

I am having problems getting an initial setup working. The ClientSecret field from AuthHelper is not used at all. Even If I delete it, the code doesn't crash. Also there are several missing informations, like how to obtain a ClientId and how to obtain a ClientSecret.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

eric-urban commented 6 years ago

@pentium10 per the doc:

You must first register an application and take note of the client ID. You'll also need your production developer token.

Good feedback on the client secret. It isn't needed to run the samples locally. Thanks!

pentium10 commented 6 years ago

How do we start without client secret?

$ php ReportRequests.php
Error: invalid_client
Description: The provided request must include a 'client_secret' input parameter.
You need to provide consent for the application to access your Bing Ads accounts. Copy and paste this authorization endpoint into a web browser and sign in with a Microsoft account with access to a Bing Ads
account:

I went to https://apps.dev.microsoft.com created an app, noted the application id

which is I think the Client ID, right please confirm? Client ID = Application ID (please mention this on the docs page).

pentium10 commented 6 years ago

further note, if you say you don't need ClientSecret, why the above fails? also why in OAuthWithAuthorizationCode.php you have "->withClientSecret($this->ClientSecret)" and that's always NULL. I expect the SDK has serious flaws, and ClientSecret from AuthHelper is not getting propagated to this line.

eric-urban commented 6 years ago

Per the OAuth guide, clients running apps on services that span regions and devices such as Microsoft Azure should register a Web app with client secret. Since the sample does not use a client secret please try adding the Native platform (not web). We will also update the get started doc to clarify. The doc already maps application to client ID i.e., "edit the ClientId with the Application Id that was provisioned when you registered your application."

pentium10 commented 6 years ago

I think I have everything setup, but still not working. I have a DeveloperToken pasted in AuthHelper. I have an app from https://apps.dev.microsoft.com used application Id to client It in PHP. Set the Environment to Production. I added a native app to the above app. No value to copy paste to PHP. Do I need to copy something from the Native App screen?

When I start the code I get this:

$ php ReportRequests.php
Error: invalid_client
Description: The provided request must include a 'client_secret' input parameter.

I didn't do anything on Microsoft Azure. What shall I do on Azure? Do I need to obtain some key from there? I am willing to do a private video call to make this running smoothly. I am struggling since Friday.

eric-urban commented 6 years ago

@pentium10 do you still see Web platform via app registration? You might need to remove it. Can you share more details about your local environment and SDK version?

You should not need to do anything via Azure to run the samples. I mentioned it as an example scenario where you would register a web app with client secret.

pentium10 commented 6 years ago

@eric-urban No I don't have anything else. This is the screen I have from https://apps.dev.microsoft.com/

Using

$ php -v
PHP 5.6.25 (cli) (built: Aug 18 2016 11:39:15)
Copyright (c) 1997-2016 The PHP Group

composer.json

{
    "require": {
        "microsoft/bingads": "v0.11.12.5"
    }
}

image

eric-urban commented 6 years ago

@pentium10 I was able to repro the same error by adding https://login.live.com/oauth20_desktop.srf to the list of custom redirect URIs per your screen capture. The error message is not intuitive/helpful in this scenario, and I'll follow up with the identity team. In the meantime please try to remove https://login.live.com/oauth20_desktop.srf from the custom list and try again. It works when I only have urn:ietf:wg:oauth:2.0:oob and https://login.microsoftonline.com/common/oauth2/nativeclient in the list.

pentium10 commented 6 years ago

@eric-urban still problems

I removed the uri from the native app section. BTW that is added automatically for you. The interface UX is extremely bad, you don't have a delete button etc... You need to empty the field.

And after that I got this error:

$ php ReportRequests.php
You need to provide consent for the application to access your Bing Ads accounts. Copy and paste this authorization endpoint into a web browser and sign in with a Microsoft account with access to a Bing Ads account:

https://login.live.com/oauth20_authorize.srf?scope=bingads.manage&client_id=<edited>&response_type=code&redirect_uri=https://login.live.com/oauth20_desktop.srf

After you have granted consent in the web browser for the application to access your Bing Ads accounts, please enter the response URI that includes the authorization 'code' parameter:

https://login.live.com/oauth20_desktop.srf?code=<edited>&lc=1033

Last SOAP request/response:
Fault Code: s:Server
Fault String: Invalid client data. Check the SOAP fault details for more information
https://clientcenter.api.bingads.microsoft.com/Api/CustomerManagement/v12/CustomerManagementService.svc?singleWsdl
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns1="https://bingads.microsoft.com/Customer/v12"><SOAP-ENV:Header><ns1:CustomerAccountId/><ns1:Cust
omerId/><ns1:DeveloperToken><edited></ns1:DeveloperToken><ns1:UserName/><ns1:Password/><ns1:AuthenticationToken><edited></ns1:Authenticat
ionToken></SOAP-ENV:Header><SOAP-ENV:Body><ns1:GetUserRequest><ns1:UserId xsi:nil="true"/><ns1:IncludeLinkedAccountIds>true</ns1:IncludeLinkedAccountIds></ns1:GetUserRequest></SOAP-ENV:Body></SOAP-ENV:Envelope>

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><s:Fault><faultcode>s:Server</faultcode><faultstring xml:lang="en-US">Invalid client data. Check the SOAP fault details for more information</faultstring><detail><Ad
ApiFaultDetail xmlns="https://adapi.microsoft.com" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><TrackingId>37fb3229-2b85-43aa-8cf0-974f3818ac10</TrackingId><Errors><AdApiError><Code>105</Code><Detail i:nil="true"/><ErrorCode>Inva
lidCredentials</ErrorCode><Message>Authentication failed. Either supplied credentials are invalid or the account is inactive</Message></AdApiError></Errors></AdApiFaultDetail></detail></s:Fault></s:Body></s:Envelope>

Fatal error: Class 'Microsoft\BingAds\Samples\V12\ReportingExampleHelper' not found in U:\fls_warehouse\bigquery\bingads\ReportRequests.php on line 141

I checked the account I have is super admin. Also checked the reporting example helper file is there, not sure why it's not locating it.

Please advise what to do.

EDIT: I wired in the class ReportingExampleHelper

and now I get this at the end of the output:

* * * Begin OutputAdApiFaultDetail * * *
 * * * Begin OutputAdApiError * * *
 Code: 105
 Detail:
 ErrorCode: InvalidCredentials
 Message: Authentication failed. Either supplied credentials are invalid or the account is inactive
 * * * End OutputAdApiError * * *
 * * * End OutputAdApiFaultDetail * * *
eric-urban commented 6 years ago

@pentium10 thanks for the heads up regarding app registration. The additional custom URIs are new and I've asked the identity team for guidance on that. We'll fix it and/or update documentation. I've also shared the feedback regarding the UI i.e., no delete button.

Regarding the 105 error please see initial guidance here. Additionally please ensure one of the following is true: 1) The developer token is registered to the same super admin who granted consent. (You can use different credentials to get the Application Id, but by default a developer token will only work with a designated Bing Ads user.) You can confirm here by logging in with the super admin and comparing the developer token. 2) OR support already upgraded your developer token to a universal token. In that case it should work with any production credentials. For more details see Account Permissions and the Developer Token.

pentium10 commented 6 years ago

@eric-urban

It's unbelievable how inmature Bings Ads SDK and interface is.

Now I have a crash on the page where Developer Tokens are visible. It persists, as it happens on FF, Chrome as well.

See the image:

image

Really really frustrating that you cannot get started with the SDK at all, it's either

Can you consolidate all these somewhere? As lots of people for sure they have frustrations.

pentium10 commented 6 years ago

@eric-urban any feedback?

eric-urban commented 6 years ago

@pentium10 regarding the "Bing Ads Developer Center has encountered some problem while processing your request" error message, can you please share more details e.g., occurs when you arrived at the site and/or when you click on the Request a token button, or other? If the support team did not answer your question on the spot via chat, please ask them to forward the question to our engineering team for further consultation. In the meantime if you prefer, please feel free to send detailed repro steps to me directly.

As you observed we do not support switching customer context in the developer portal. This is the first time I've heard the request, although its a fair point i.e., makes sense to show all of the users that your Super Admin credentials can access. Can you share more details about the scenario and requirement? You could just get one developer token for use with any credentials (if upgraded to a universal developer token), in which case switching customer context in the developer portal might not be necessary.

Regarding "undocumented error that you cannot figure out why Native App has mislead to an error which you cannot control (totally blocked)" I did follow up with the Microsoft identity team and this unexpected error impacts apps registered between August 30 - September 5th. It was not expected for this scenario, and the issue has been resolved going forward for all new apps that are registered. For apps created between August 30 - September 5th, the workaround is to delete the additional custom URIs as mentioned above. I also shared your feedback with the team regarding no 'x' or 'delete' button for the custom URIs. Thank you for that!

We do have documentation on client ID and client secret e.g., here and here. There is opportunity to clarify i.e., add more details in the walkthrough. I will follow up on that part, before closing out this issue.

Best regards, Eric

pentium10 commented 6 years ago

as far I can tell, if I change the customer context on Bing Ads center, then go to this page by typing the url the page comes back with the errror

it's easy to reproduce:

  1. go to https://developers.bingads.microsoft.com/Account you see it's not the good context, then you go to switch context to step 2
  2. get into: https://ui.bingads.microsoft.com/campaign/accountssummary?cid=4007549#customer/4007549/accounts-summary/performance switch the customer account
  3. go back to previous page, it crashed,
  4. switching context again, still crashed

you need to clear cookies or logout to get going again, and only works correctly for the 'default' account that's loading for you, but when you change contexts it stops working for all situations I cannot access dev tokens only for the default page, not for other accounts.

as regarding client ID client Secret you generally when you need to find something you search on the internet when searching something you expect a clear page like for example I was stucked to find a value to paste for client secret, and because of this I didn't read the entire page, so there should be a page which tells you when

the simplest page that has how to obtain develoepr token link, then client id link, client secret link could actually help

also it would be good to mention what a native app is, what a web app is, what an api is good as you probably stop reading the flow when you develop a Worker for a SDK data pull task

I think pages are too long, and there are no index pages, which could guide you to the right reading page

eric-urban commented 6 years ago

Closing the current issue since we have clarified details about ClientId in this doc. Dev portal feedback has been shared with the team.