Giter Site home page Giter Site logo

Comments (20)

JanTvrdik avatar JanTvrdik commented on June 26, 2024

You need to use namespace, i.e. Milo\Github\OAuth\Login.

from github-api.

TheZoker avatar TheZoker commented on June 26, 2024

Ah ok works :) Thank you!
I now get something like this on var_dump:
img_2015 09 15_20h45m12s_005_

And when i simple return the token, I don`t get any output.

How can I get the token out of this?

from github-api.

JanTvrdik avatar JanTvrdik commented on June 26, 2024

You need to load github-api.php (or setup autoloading) before calling session_start.

from github-api.

TheZoker avatar TheZoker commented on June 26, 2024

Yep I`m doing that, otherwise I would not get this response I guess.

from github-api.

JanTvrdik avatar JanTvrdik commented on June 26, 2024

No, __PHP_Incomplete_Class means that at the time of session_start the class Milo\Github\OAuth\Token is undefined.

from github-api.

TheZoker avatar TheZoker commented on June 26, 2024

img_2015 09 15_20h55m37s_006_
This is my code
Without the github-api.php I would not be able to use Milo\Github\OAuth\ and these stuff, right?

from github-api.

JanTvrdik avatar JanTvrdik commented on June 26, 2024

Strange. Do you have error_reporting set to E_ALL and enabled display_errors?

from github-api.

milo avatar milo commented on June 26, 2024

@TheZoker Try to dump the $_SESSION content. Isn't there some garbage? If so, clean it somehow.

The library uses $_SESSION['milo.github-api']. Isn't touched by another app?

from github-api.

TheZoker avatar TheZoker commented on June 26, 2024

This is the dump of $_SESSION
img_2015 09 15_21h14m30s_008_
I use it to build a wordpress plugin, so it should be untouched

from github-api.

milo avatar milo commented on June 26, 2024

Try unset($_SESSION['milo.github-api']) directly after the session_start(). Only once and remove it. Then, try whole auth roundtrip again.

from github-api.

milo avatar milo commented on June 26, 2024

Oh, maybe I got it. Isn't session started somewhere earlier? I mean, your session_start() in oauth() function is the second call.

from github-api.

TheZoker avatar TheZoker commented on June 26, 2024

But I dont have any other session_start() anywhere else

from github-api.

milo avatar milo commented on June 26, 2024

Wordpress does not start it? Or maybe PHP's session.auto_start? Try var_dump(session_status()); before the require_once ...;

from github-api.

TheZoker avatar TheZoker commented on June 26, 2024

img_2015 09 15_21h38m20s_009_
So there is another plugin uses the session

Btw: How can I open the oauth window in a new window (popup)?

from github-api.

milo avatar milo commented on June 26, 2024

I see. So, session is somewhere already started before you load the github-api libs. I don't know the Wordpress, maybe there is some hook for plugins to load the libraries first.

If not, you can try this nasty hack in here and let me know.

public function getToken()
{
    $token = $this->storage->get('auth.token');
    if ($token === NULL) {
        throw new Github\LogicException('Token has not been obtained yet.');
    } elseif ($token instanceof \__PHP_Incomplete_Class) {
        $token = unserialize(serialize($token));
    } 
    return $token;
}

from github-api.

milo avatar milo commented on June 26, 2024

Btw: How can I open the oauth window in a new window (popup)?

Sorry, that's the frontend thing which I don't solve.

from github-api.

TheZoker avatar TheZoker commented on June 26, 2024

I can`t test it, because I get this error:
img_2015 09 15_21h58m30s_011_
https://github.com/TheZoker/GithubTemp/blob/master/helper.php#L16
https://github.com/TheZoker/GithubTemp/blob/master/ajax.php
https://github.com/TheZoker/GithubTemp/blob/master/assets/script.js

Thank you very much for your help!

from github-api.

milo avatar milo commented on June 26, 2024

@TheZoker The error is caused by the Same Origin Policy setting. It is not relevant to this library.

Anyway, I released a new version 1.4.3 where is a token in session stored as an ordinary array. It prevents __PHP_Incomplete_Class error.

from github-api.

TheZoker avatar TheZoker commented on June 26, 2024

@milo Is there any way to generate and save a state without calling askPermissions() ?

from github-api.

milo avatar milo commented on June 26, 2024

No, if you need a user's permissions. Btw. why do you access GitHub webpage by AJAX? You need to redirect a browser window. User will click 'Accept' on GitHub web and than will be redirected back to your site.

from github-api.

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.