Question

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

Was it helpful?

Solution

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.

OTHER TIPS

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.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top