Sync Chrome extension login with web app (Next JS) - google-chrome

I'm trying to sync chrome extension and web app login. I'm currently using Next Auth to get the access token for a provider. Any one has experience with it ? I am able to send message from the web app to the extension with the access token, but not sure how I can authenticate the user in the extension.

You can get Google auth token and authenticate the user, it will ask user to choose g-profile & login. Here is code that works for me:
backgroung.js:
chrome.identity.getAuthToken({ 'interactive': true }, function(token) {
console.log("token: " + token);
});

Related

Yii2 : AuthClinet + Facebook login

i've create a Facebook login app and it works fine when it on localhost but when I published it online it gives me an error :
Can't Load URL: The domain of this URL isn't included in the app's domains. To be able to load this URL, add all domains and subdomains of your app to the App Domains field in your app settings.
i've update the app setting to be :
App Domains : *******.com
and also
Site URL :https://********.com/
and in Facebook login app setting is
Client OAuth Login : No
but error still appears

gdrive command line oauth2: cannot fetch token: 400 Bad Request

Suddenly, gdrive command line tool stops working, and always gives the following error message:
Failed to get about: Get https://www.googleapis.com/drive/v3/about?alt=json&fields=maxImportSizes%2CmaxUploadSize%2CstorageQuota%2Cuser: oauth2: cannot fetch token: 400 Bad Request
Response: {
"error": "invalid_grant",
"error_description": "Bad Request"
}
This is because your authorization token has expired.
Currently there is an open Issue to improve this error message here.
You should delete your token with rm ~/.gdrive/token_v*.json
then run the gdrive about command to reauthorize
The steps I fixed it:
rm ~/.gdrive/token_v2.json as other answer suggested.
But I get danger error if I open the link get from gdrive about to re-authorize:
So I create a drive project by go to https://developers.google.com/drive/api/v3/quickstart/js and click "Enable the Drive API":
Click the "API Console" link on that dialog:
To make default redirect url (i.e. urn:ietf:wg:oauth:2.0:oob) works, we need Installed type app and can't use "Web application type app"(which only allow http/https scheme). So click "Create credentials" and choose "Oauth client ID" item:
Ensure select "Other" type:
Copy "Client ID" and "Client secret" from created item. cd to ~/.go/src/github.com/prasmussen/gdrive/, then replace both at this two variables in handlers_drive.go file, save it, e.g.:
const ClientId = "xxx.apps.googleusercontent.com"
const ClientSecret = "xxx"
Then run go install at that directory. Now run gdrive about and open that link in web browser. I get This app isn't verified error page. You are the author who created that app on above steps and suppose safe. Nevertheless simply click "Advanced" link and click Go to Quickstart (unsafe) link:
Click "Allow" it, copy/paste the code back to gdrive about and done:
Managed to resolve this by retriggering gcloud authorization with:
gcloud auth application-default login

com.google.api.client.auth.oauth2.TokenResponseException: 401 Unauthorized in google drive service account

Credential credential = new GoogleCredential.Builder()
.setTransport(HTTP_TRANSPORT)
.setJsonFactory(JSON_FACTORY)
.setServiceAccountId("gdriveconnector#testconnector-205108.iam.gserviceaccount.com")
// .setServiceAccountPrivateKeyFromP12File(new File("/GoogleDriveSrvcAcnt-4d4a3f9e9059.p12"))
.setServiceAccountPrivateKey(serviceAccountPrivateKey)
.setServiceAccountScopes(scopes)
.setServiceAccountUser("user#sdfj.com")
.build();
I am passing email id of admin in account user still this error persists.
Your are using either an expired or invalid token access token.
Suggested action: Refresh the access token using the long-lived
refresh token. If this fails, direct the user through the OAuth flow,
as described in Authorizing Your App with Google Drive.

Postman Oauth 2 callback url - Chrome App

I am using The Chrome App for Postman and I am setting up my Access Tokens using OAUTH2. When I fill out the form, I am using the following:
Auth Url: https://[MY_API_URL]/api/authorize
Access Token URL: https://[MY_API_URL]/api/request/token
Client ID: xxxxxxxxxxx
Client Secret: xxxxxxxxxx
Scope: blank
Grant Type: Authorization Code
The callback url in my outh server is set to "https://www.getpostman.com/oauth2/callback"
When I click Request Token, I am taken to the proper Authentication page. When I submit my credentials, a new Chrome tab opens up with a blank page with the url https://app.getpostman.com/oauth2/callback?code=xxxxxxxxxx
I expect that this is supposed to redirect to the app so it can perform the access token request. from the access token url, but nothing is happening. Is this not the right callback uri?
This is an old question and things have changed since.
Google deprecated Chrome Apps, so Postman had to deprecate their old Chrome App client too, and so the old redirection URL (https://www.postman.com/oauth2/callback) no longer works.
According to this, with the more recent versions of Postman, the new redirection URL is https://oauth.pstmn.io/v1/callback.
You have change your permission type. Use Client Credentials instead of Authorization
I also faced same problem.
Just change Grant Type: Authorization Code to Grant Type: Client Credentials.
It worked for me.
Certainly as mentioned in other comments, for client_credentials it would work but for the Implicit or Authorization Code, I used "https://app.getpostman.com/oauth2/callback" as the callback url and it worked. Also it need to be configured in the application settings in oauth provider.
I've been using this callback url:
https://getpostman.com/oauth2/callbackurl

Yii2 authclient Error: redirect_uri_mismatch

I am implementing yii2 authclient, I created the client id in in google api console this is the redirect url I created in gogle console with the corresponding client id.
http://mysite.x10host.com/oauth2callback
when I access my site login this is how it looks like
http://mysite.x10host.com/home/mysitex/public_html/web/site/login
when I click the the google icon
That’s an error.
Error: redirect_uri_mismatch
Application: Project Default Service Account
You can email the developer of this application at: myemail#gmail.com
The redirect URI in the request: http://mysite.x10host/home/mysitex/public_html/web/site/auth?authclient=google
can someone help me on this.
Thank you in advance