Code Monkey home page Code Monkey logo

Comments (3)

dacastro4 avatar dacastro4 commented on June 8, 2024

@stacybot123 can you elaborate more please

from laravel-gmail.

Stacey940 avatar Stacey940 commented on June 8, 2024

@dacastro4 , thank you for quick reply. I am using this SDK from a while and I love this. Thank you for putting efforts in making this.

The state variable can be used to send a custom value with with the OAuth request. For example : if every user on the app have their custom subdomain (wildcard subdomain) it is impossible to add each of them on the google app, or to disable cross site forgery. So google can pass the state with the request and identify the user and redirect back to the correct resource.
If I use the google client directly it can be used as below:

            $client = new Google_Client();
            $client->setClientId('XXXXXXXXXXXX');
            $client->setClientSecret('XXXXXXXXXXXXX');
            $client->setAccessType('offline'); 
            $client->addScope(Google_Service_Gmail::GMAIL_SEND);
            $client->setRedirectUri('https://app.example.com/oauth2callback');
            $client->setState('mycustom_value');
            $client->setIncludeGrantedScopes(true);
            $auth_url = $client->createAuthUrl();
            header('Location: ' . filter_var($auth_url, FILTER_SANITIZE_URL));

The data it will receive after the OAuth validation on server will look like this:

array (
  'state' => 'mycustom_value',
  'code' => 'XXXXXXXXXXXXXXXXXXX',
  'scope' => 'https://www.googleapis.com/auth/gmail.send',
)  

Here is the doc on google which have the info

from laravel-gmail.

dacastro4 avatar dacastro4 commented on June 8, 2024

@stacybot123 I check the code and I don't have the state as a variable that can be set.

from laravel-gmail.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.