Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InvalidArgumentException in Client.php line 433: Invalid token format #39

Closed
Artanty opened this issue Nov 14, 2018 · 15 comments
Closed

Comments

@Artanty
Copy link

Artanty commented Nov 14, 2018

Hello! Help me pls!

  1. Can't understand how to modify the config file config/gmail.php.
    What to do inside of it?
    project id,client id,client secret and redirect I set in .env file.
    Is it necessary to do something with this string ↓ ?
    'credentials_file_name' => env( 'GOOGLE_CREDENTIALS_NAME', 'gmail-json' ),

  2. I downloaded .json credentials file from google console, pasted it to:
    "[my project]/storage/app/gmail/tokens"
    then I renamed it to: 'gmail-json.json'
    Is it right?

@Artanty Artanty changed the title AuthException in LaravelGmailClass.php line 30: No credentials found. InvalidArgumentException in Client.php line 433: Invalid token format Nov 14, 2018
@Artanty
Copy link
Author

Artanty commented Nov 14, 2018

After that I go to index page where I inserted:

{{ LaravelGmail::user() }}

@if(LaravelGmail::check()) logout @else login @endif

and get "Invalid token format" until I delete this check

@fajarainul
Copy link

did you found any solution?

@Artanty
Copy link
Author

Artanty commented Nov 20, 2018

no, please help me!

@fajarainul
Copy link

I am stuck too. I already did exactly what you did. Set values in .env, download json file provided by Google console and also put it into storage/app/gmail/tokens. One thing I know is we must provide access_token, refresh_token, and expires_in inside credentials.json, but I dont know the proper way to afford this.

@pqrs
Copy link

pqrs commented Nov 22, 2018

@Artanty, @fajarainul, any news? I'm stuck here too.

@Artanty
Copy link
Author

Artanty commented Nov 23, 2018

No, i tried another library and wrapper for connect to gmail via api, but nothing.
Although gCalendar api and socialite with Google auth work fine.

@dacastro4
Copy link
Owner

Hey guys I have an example of my gmail-json.json

{
  "access_token": "ACCESS",
  "token_type": "Bearer",
  "expires_in": 3600,
  "refresh_token": "REFRESH",
  "created": 1522885414,
  "email": "EMAIL"
}

My .env

GOOGLE_PROJECT_ID=PROJECT_ID
GOOGLE_CLIENT_ID=ID.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=SECRET
GOOGLE_REDIRECT_URI=/oauth/gmail/callback

Hope it helps.

@Artanty
Copy link
Author

Artanty commented Nov 24, 2018

Hope it helps.

Yes, it helped!
I realized that my mistake was not in gmail-json.json
I simply wrote "GOOGLE_APP_SECRET" instead of "GOOGLE_CLIENT_SECRET" in .env file.

Thank you!

@dacastro4
Copy link
Owner

I'm really glad to hear that @Artanty

@Artanty
Copy link
Author

Artanty commented Nov 24, 2018

I am stuck too. I already did exactly what you did. Set values in .env, download json file provided by Google console and also put it into storage/app/gmail/tokens. One thing I know is we must provide access_token, refresh_token, and expires_in inside credentials.json, but I dont know the proper way to afford this.

We don't need to download .json file and put it into storage/app/gmail/tokens.
This file is creating automatically on callback function "LaravelGmail::makeToken();"
delete it if you put it into storage/app/gmail/tokens.

@Artanty Artanty closed this as completed Nov 24, 2018
@pqrs
Copy link

pqrs commented Nov 26, 2018

Thanks @dacastro4 but I must be doing something wrong. I don't know if it is in the config or in the Google console. Is there any step by step tutorial or any working example somewhere I can look at?

@dacastro4
Copy link
Owner

@pqrs what kind of error are you getting?

@pqrs
Copy link

pqrs commented Nov 27, 2018

No credentials found.

@pqrs
Copy link

pqrs commented Nov 27, 2018

Solved! It works now... nothing like restart from the beginning! :)

@iqroyan
Copy link

iqroyan commented Jul 1, 2019

Hey guys I have an example of my gmail-json.json

{
  "access_token": "ACCESS",
  "token_type": "Bearer",
  "expires_in": 3600,
  "refresh_token": "REFRESH",
  "created": 1522885414,
  "email": "EMAIL"
}

My .env

GOOGLE_PROJECT_ID=PROJECT_ID
GOOGLE_CLIENT_ID=ID.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=SECRET
GOOGLE_REDIRECT_URI=/oauth/gmail/callback

Hope it helps.

hey Danial access_token same of GOOGLE_CLIENT_ID?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants