コード例 #1
0
 public function testCreateAuthUrl()
 {
     $oauth = new Google_OAuth2();
     $oauth->developerKey = "devKey";
     $oauth->clientId = "clientId1";
     $oauth->clientSecret = "clientSecret1";
     $oauth->redirectUri = "http://localhost";
     $oauth->approvalPrompt = 'force';
     $oauth->accessType = "offline";
     $authUrl = $oauth->createAuthUrl("http://googleapis.com/scope/foo");
     $expected = "https://accounts.google.com/o/oauth2/auth" . "?response_type=code" . "&redirect_uri=http%3A%2F%2Flocalhost" . "&client_id=clientId1" . "&scope=http%3A%2F%2Fgoogleapis.com%2Fscope%2Ffoo" . "&access_type=offline" . "&approval_prompt=force";
     $this->assertEquals($expected, $authUrl);
 }
コード例 #2
0
 private function checkIdTokenFailure($id_token, $msg)
 {
     $certs = $this->getSignonCerts();
     $oauth2 = new Google_OAuth2();
     try {
         $oauth2->verifySignedJwtWithCerts($id_token, $certs, "client_id");
         $this->fail("Should have thrown for {$id_token}");
     } catch (Google_AuthException $e) {
         $this->assertContains($msg, $e->getMessage());
     }
 }