Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome Identity API - POST request

I am trying to develop a chrome extension in which I need to use 3rd party Oauth2 authentication. The third party service I want to use, only supports POST requests. But it seems that the launchWebAuthFlow method in the Chrome Identity API, only supports sending GET requests, as all the query parameters are sent in the URL itself. Is this correct? If yes, how should I do authentication?

UPDATE : The API I want to connect is that of Pocket

like image 521
user2302124 Avatar asked Nov 27 '25 07:11

user2302124


2 Answers

Partially you're right about POST requirements. But it is only used to initialize Oauth flow. According to the documentation:

1) You must make a POST request to obtain a request token from Pocket auth service

2) Redirect user to the auth page: https://getpocket.com/auth/authorize?request_token=YOUR_REQUEST_TOKEN&redirect_uri=YOUR_REDIRECT_URI

Which means that you have to make a simple XHR to retrieve request token and then you can use chrome.identity.launchWebAuthFlow function to begin Oauth flow.

like image 109
Pawel Psztyc Avatar answered Nov 28 '25 23:11

Pawel Psztyc


Did you try launchWebAuthFlow? You may find that it works. Once authenticated, you can exercise the API via POST, using XMLHttpRequest. (launchWebAuthFlow only handles the authentication, not the API itself.)

like image 31
Marc Rochkind Avatar answered Nov 28 '25 23:11

Marc Rochkind