Vào 3:04, Th 6, 24 thg 6, 2022 Dmitry M <nsk...@gmail.com> đã viết:
> Team, > > After Google blocked the 'less secure apps' access to Gmail and such I'm > trying to rewrite my client code to use Google's OAuth2 API. > > But I'm stuck w/the notorious 'invalid_grant' issue. > Here, pay attention: this is about the very 'second' step - exchanging > authorization code to the tokens very first time. > > My general approach: > > - I'm sending a request to get the authorization code from the browser > (simply putting it in the address box): > > > https://accounts.google.com/o/oauth2/v2/auth?scope=https%3A//www.googleapis.com/auth/gmail.addons.current.message.action&access_type=offline&include_granted_scopes=true&response_type=code&state=state_parameter_passthrough_value&redirect_uri=https%3A//localhost/code&client_id= > <client_id_here> > > - I'm receiving an OK response w/the authorization code alright > > - I'm sending then an HTTP POST (from the same browser console like) > > var url = 'https://oauth2.googleapis.com/token'; > > var params = > 'code=<code-here>&client_id=<client-id-here>&client_secret=<client-secret-here>&redirect_uri=http%3A//localhost&grant_type=authorization_code'; > > var http = new XMLHttpRequest(); > > http.open('POST', url, true); > > http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); > > http.send(params); > > - I'm receiving response like > > { > "error": "invalid_grant", > "error_description": "Bad Request" > } > > Can anyone please advise? > > Thanks. > > -- > -- > =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ > Also find us on our blog: > https://googleadsdeveloper.blogspot.com/ > =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ > > You received this message because you are subscribed to the Google > Groups "AdWords API and Google Ads API Forum" group. > To post to this group, send email to adwords-api@googlegroups.com > To unsubscribe from this group, send email to > adwords-api+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/adwords-api?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Google Ads API and AdWords API Forum" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to adwords-api+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/adwords-api/05d7658b-bb76-4ecf-a517-05497f382814n%40googlegroups.com > . > -- -- =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ Also find us on our blog: https://googleadsdeveloper.blogspot.com/ =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ You received this message because you are subscribed to the Google Groups "AdWords API and Google Ads API Forum" group. To post to this group, send email to adwords-api@googlegroups.com To unsubscribe from this group, send email to adwords-api+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/adwords-api?hl=en --- You received this message because you are subscribed to the Google Groups "Google Ads API and AdWords API Forum" group. To unsubscribe from this group and stop receiving emails from it, send an email to adwords-api+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-api/CAGPr9nLv_Hfbcse3wiNT2n4zN5mo_%3DTsji4nQ8HoFjMBHf9uJQ%40mail.gmail.com.