chrome extension launchWebAuthFlow error - google-chrome-extension

chrome.identity.launchWebAuthFlow
method always throw error Authorization page could not be loaded.
When requesting with:
"&redirect_uri=http://localhost:8080"
the Google's auth popup appears but after you sign in: error appears.
"&redirect_uri=" + chrome.identity.getRedirectURL() error throws immediately
I need to login Google from Opera extension so getAuthToken will not work for me.

I have found soluntion. You should create "Web app" with redirect uri=https://<appid>.chromiumapp.org/ when creating oauth2 client in google dev console instead of "chrome app".

Related

Facebook Socialite Error 404: Page not found

I am setting up Facebooking socialite on my existing website and encountered an 404 error when I click "Login With Facebook " button. The error is:
Sorry, the page you are looking for could not be found.
I don't know whether the error is from the routing or it is from something else.
The designate url for the button is: https://ktest1.domainforplaying.com/auth/redirect/facebook
You need to setup routes for socialite to use to connect to Facebook. Please see the official documentation:
https://laravel.com/docs/6.x/socialite#routing

Account linking returns errors

I am facing issue with account linking in google action console. What should be parameter in the https://oauth-redirect.googleusercontent.com for successful account linking and redirecting me back to simulator?
Firstly I have used auth0 for account linking. It was successful v.i.a simulator i.e It was opening the auth0 login page where I logged in and it was showing me "Account Linking Successful" and redirecting me back to google simulator page for further testing. But when I used my website for authentication It is returning error while Account linking.
https://oauth-redirect.googleusercontent.com/r/airpurifier-dlfvrq?state=MY_STATE&access_token=KkvQ85d36b1ebcf0cea06a5148236tdVEp&token_type=bearer
returns "The parameter "code" or "error" must be set in the query string". as error message
When I intentionally add
https://oauth-redirect.googleusercontent.com/r/airpurifier-dlfvrq?state=MY_STATE&access_token=KkvQ85d36b1ebcf0cea06a5148236tdVEp&token_type=bearer&code=200
An error occurred in returning the result.
I have followed the entire documentation from https://developers.google.com/actions/identity/oauth2
Any help will be appreciated. Thanks.
As per the documentation the return URL should be in below format:
https://oauth-redirect.googleusercontent.com/r/YOUR_PROJECT_ID#access_token=ACCESS_TOKEN&token_type=bearer&state=STATE_STRING
Notice that you are using "?" after project ID which should be "#". Change it and try. It should work.

chrome extension call to gmail api

I am really new creating chrome extensions. I am trying to use Gmail API in my extension to get the Thread Id from sent email folder. I have used this tutorial:
https://medium.com/streak-developer-blog/how-to-use-the-gmail-api-in-a-chrome-extension-a272b2405b57
When I use the function getThreads(query, labels),
https://gist.github.com/omarstreak/7908035c91927abfef59
I did not get nothing. Also when I review the background console appear this error:
Unchecked runtime.lastError while running identity.getAuthToken: OAuth2 request failed: Service responded with error: 'bad client id: {0}'
I have created my own client_id and I put it in my manifest.
"oauth2": {
"client_id": "27599747390-.................apps.googleusercontent.com",
"scopes": [
"https://www.googleapis.com/auth/gmail.modify"
]
},
Have someone some tutorial or sample that works about using Gmail API in chrome extensions?.
Yes, there is actually a sample in the documentation. See this method if your purpose is to get a specified thread. Also to guide you accordingly, here is a github post to help you more on chrome extension essentials.

Is it possible to make oauth 2.0 requests using background page of chrome extensions?

I have javascript code running in the background page of my chrome extension which calls Google api. The code below essentially requests for oAuth2 token.
function init(){
gapi.client.setApiKey(apiKey);
console.log("Initializing...");
gapi.auth.init(function() { setTimeout(authenticate,100)});
}
function authenticate(){
console.log("Initialized. Now AUthenticating");
gapi.auth.authorize({client_id: clientId, scope: scopes, immediate: false},api);
}
The auth window opens as expected, however after user logs in and permits my app, the page merely freezes. The callback (api()) is never made and I dont receive a token. Is it because I'm calling it from a background page and the auth window has no way of sending a response back?
If yes, what is the workaround/ solution?
If so, how can I fix this?
You can use Boris Smus's OAuth 2.0 Library for Chrome Extension. It works great in my extension.
The reason why you cannot use OAuth2.0 in chrome extension:
Chrome extensions can't directly use the OAuth 2.0 server-side or
client-side flows because they live at chrome-extension:// URLs

Using OAuth dialog for facebook app do not allow to use canvas URL as redirect_uri

I am starting a Facebook app. Following the Getting Started tutorial in the Authorization section, it says I should use this URL to get permission from users:
https://www.facebook.com/dialog/oauth?client_id=YOUR_APP_ID&redirect_uri=YOUR_CANVAS_PAGE
I am replacing YOUR_CANVAS_PAGE with my canvas URL, the one I see on my app settings:
https%3A%2F%2Fapps.facebook.com%2F238620302882463%2F
But, then, if I navigate to that page, I get the following error:
An error occurred with Elecciones 2012. Please try again later.
API Error Code: 191
API Error Description: The specified URL is not owned by the application
Error Message: Invalid redirect_uri: Given URL is not allowed by the Application configuration.
If I replace YOUR_CANVAS_PAGE with:
http%3A%2F%2Fwww.example.com%2FElecciones2012
The permission dialog works fine. But then I get redirected to my website, not the app inside facebook.com
Any idea why is this happening??
I have seen other apps using a different permission dialogue:
http://www.facebook.com/connect/uiserver.php?app_id=11609831134&method=permissions.request&redirect_uri=http%3A%2F%2Fapps.facebook.com%2Fpetsociety%2F%3Fpf_ref%3Dsb%26ref%3Dts&response_type=none&display=page&perms=email%2Cpublish_actions&auth_referral=1
But it looks it is part of another set of APIs.
I got the same problem too. Looks like the problem is in "Canvas URL". You cannot use your app id in canvas URL like:
"https%3A%2F%2Fapps.facebook.com%2F238620302882463%2F"
Instead, the namespace should be used as your canvas URL. for example:
"https://apps.facebook.com/myapplication/"
You can set your app namespace in the application settings in facebook.

Resources