Oauth2l authentication

1,511 views
Skip to first unread message

Abhishek Rajpoot

unread,
Sep 14, 2023, 1:55:52 PM9/14/23
to Google Ads API and AdWords API Forum
I trying to make an api call to generate the refresh token by making an google ad api, I am stuck at the oauth authentication where I am unable to run this command

oauth2l fetch --credentials credentials.json --scope adwords \
   
--output_format refresh_token


I'm getting this error, If I am adding scope flag 


usage: oauth2l [-h] {fetch,header,reset,info,test} ...
oauth2l: error: unrecognized arguments: --scope


and if It is removed, it says scope is required! 

Google Ads API Forum Advisor

unread,
Sep 15, 2023, 7:47:06 AM9/15/23
to manu.ab...@gmail.com, adwor...@googlegroups.com
Hi,

Thank you for reaching out to the Google Ads API support team.

After reviewing your concern, I understand that you are trying to make a call to Google Ads API to generate the refresh token but getting an error "unrecognized arguments" while adding the scope flag.

I would recommend you to check this guide to make sure that you have followed all the steps to fetch a refresh token. 

All Google Ads API calls must be authorized through OAuth2. OAuth2 enables your Google Ads API client app to access a user's Google Ads account without having to handle or store the user's login info. To know more about the steps that must be completed to authorize requests to the Google Ads API, I would suggest you refer to this guide.

If the issue still persists, please provide us with the complete API logs (request and response with request-id and request header) generated at your end so that we can better assist you.

If you are using a client library and haven't enabled the logging yet, I would request you to enable logging for the specific client library that you are using. You can refer to the guides Java.NetPHPPythonRuby or Perl to enable logging at your end. For REST interface requests, you can enable logging via the curl command by using the -i flag.


 
This message is in relation to case "ref:_00D1U1174p._5004Q2olRy2:ref"

Thanks,
 
Google Logo Google Ads API Team

 

Abhishek Rajpoot

unread,
Sep 18, 2023, 1:58:35 AM9/18/23
to Google Ads API and AdWords API Forum
Hello all,

Solution Tried: 
I could not implement the mentioned command in Windows because if I have installed the oauth2l using pip, then it does not recognize the provided flags. Additionally, the documentation for this package isn't very clear. I tried the same command (mentioned below) in Ubuntu, and it successfully opens the consent screen.

oauth2l fetch --credentials credentials.json --scope adwords \ --output_format refresh_token

Blocker:
However, I am again facing an issue. The consent screen URL contains the callback URL. I have created a dummy server with the same endpoint as mentioned in the URL. However, when the login is successful, it just makes a GET API request to the server with an empty body.
How am I supposed to get the refresh token?

Google Ads API Forum Advisor

unread,
Sep 20, 2023, 8:38:03 AM9/20/23
to manu.ab...@gmail.com, adwor...@googlegroups.com
Hi,

Thank you for getting back to us.

After reviewing your concern, I understand that your query is regarding refresh token. You can get a refresh token on OAuth2 Playground, in conjunction with the Google API Console. For that you need a client ID and client secret, I would recommend you to check this guide to get a client ID and client secret and follow all the steps to get a refresh token. In addition, I would suggest you refer to this guide to Set up a Google API Console project.
Reply all
Reply to author
Forward
0 new messages