Closed chiragvels closed 4 years ago
It is giving me error after getting code
Microsoft\BingAds\Auth\OAuthTokenRequestException in /var/www/html/bingads/vendor/microsoft/bingads/src/Auth/UriOAuthService.php:106 Stack trace: #0 /var/www/html/bingads/vendor/microsoft/bingads/src/Auth/OAuthWithAuthorizationCode.php(100): Microsoft\BingAds\Auth\UriOAuthService->GetAccessTokens(Object(Microsoft\BingAds\Auth\OAuthRequestParameters), 'Production', false) #1 /var/www/html/bingads/vendor/microsoft/bingads/samples/WebAuthentication/OAuth2Callback.php(64): Microsoft\BingAds\Auth\OAuthWithAuthorizationCode->RequestOAuthTokensByResponseUri('localhost/...') #2 {main}
@chiragvels I'll investigate and get back to you. Thanks!
Thanks @eric-urban , I think this works with MSIdentityV2 platform, but not finding option to add consent screen.
I wanted to ask user to authenticate and give consent every time when they try to authenticate.
Thanks,
@chiragvels have you tried implicit grant flow via OAuthDesktopMobileImplicitGrant? Otherwise the authorization URL can be updated for example with 'prompt=login' or 'prompt=consent'.
Yes, I was trying OAuthDesktopMobileImplicitGrant, but let me add 'prompt=login' or 'prompt=consent' this at end of Forming Authorization Url.
@chiragvels you can append the login and/or consent prompt to the SDK authorization endpoint. For example I appended "&prompt=login%20consent" below.
static function RequestUserConsent()
{
print "You need to provide consent for the application to access your Microsoft Advertising accounts. " .
"Copy and paste this authorization endpoint into a web browser and sign in with a Microsoft account " .
"with access to a Microsoft Advertising account: \n\n" . $GLOBALS['AuthorizationData']->Authentication->GetAuthorizationEndpoint() .
"&prompt=login%20consent". "\n\nAfter you have granted consent in the web browser for the application to access your Microsoft Advertising accounts, " .
"please enter the response URI that includes the authorization 'code' parameter: \n\n";
$responseUri = fgets(STDIN);
print "\n";
$GLOBALS['AuthorizationData']->Authentication->RequestOAuthTokensByResponseUri(trim($responseUri));
AuthHelper::WriteOAuthRefreshToken($GLOBALS['AuthorizationData']->Authentication->OAuthTokens->RefreshToken);
}
Note, the original RequestUserConsent sample is available in AuthHelper.php.
Will this work for you?
Hi @eric-urban ,
I was recently facing issue with this line.
Here I am not getting any values. An simply throws me error.
Can I know exact reason for same?
Does this example or API will not work if we have old credentials? and not Microsoft identity platform?
Thanks,
Hi,
Does Library example for oAuth2callback.php is supported for Microsoft identity platform endpoint?
Please suggest PHP documentation for same.
How I can use prompt=login with MSIdentityV2 platform?
Thanks,