Skip to content
This repository was archived by the owner on Feb 5, 2024. It is now read-only.

UsingGithubToken fails for .com: invalid character '<' looking for beginning of value #69

Closed
probonopd opened this issue Nov 23, 2019 · 6 comments

Comments

@probonopd
Copy link

probonopd commented Nov 23, 2019

The following code works for travis .org but fails for .com - why?

The error I get with .com is:

client.Authentication.UsingGithubToken: invalid character '<' looking for beginning of value
	fmt.Println("Is your repository on travis.com? Answer 'no' if org (yes/no)")
	var client *travis.Client
	var travisSettingsURL string
	if AskForConfirmation() == true {
		fmt.Println("Assuming your repository is on travis.com")
		client = travis.NewClient(travis.ApiComUrl, "")
		travisSettingsURL = "https://travis-ci.com/" + repoSlug + "/settings"
	} else {
		fmt.Println("Assuming your repository is on travis.org")
		client = travis.NewClient(travis.ApiOrgUrl, "")
		travisSettingsURL = "https://travis-ci.org/" + repoSlug + "/settings"
	}

	_, response, err := client.Authentication.UsingGithubToken(context.Background(), token)
	if got, want := response.StatusCode, 200; got != want {
		fmt.Println("UsingGithubToken fails: invalid http response %s", response.Status)
	}

	if err != nil {
		fmt.Println("client.Authentication.UsingGithubToken:", err)
		fmt.Println("This can mean that the token is invalid or has not enough rights in its scope")
		fmt.Println("FIXME: Authentication seems to only work for .org but not for .com right now") // FIXME
		os.Exit(1)
	}
@probonopd
Copy link
Author

Please add a test for .com to

as := &AuthenticationService{client: NewClient(ApiOrgUrl, token)}

and similar tests as well.

@shuheiktgw
Copy link
Owner

shuheiktgw commented Nov 26, 2019

Thanks for reporting the issue! Hmm, I'll check what is wrong with the AuthenticationService, so please give me some time or feel free to send me a PR! 👍

@probonopd
Copy link
Author

How can I see the HTML response that contains the invalid character '<' it complains about?

@shuheiktgw
Copy link
Owner

Sorry for taking so much time to investigate this issue. This is the response I got from their API.

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Travis CI - Test and Deploy with Confidence</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="icon" type="image/png" href="https://cdn.travis-ci.com/images/favicon-076a22660830dc325cc8ed70e7146a59.png" />

    <script src="https://cdn.travis-ci.com/check-browser-support-a53758c2cbd69293e76543362b2b4155.js" async></script>


<meta name="travis/config/environment" content="%7B%22modulePrefix%22:%22travis%22,%22environment%22:%22production%22,%22rootURL%22:%22/%22,%22locationType%22:%22auto%22,%22defaultTitle%22:%22Travis%20CI%20-%20Test%20and%20Deploy%20with%20Confidence%22,%22providers%22:%7B%22assembla%22:%7B%22endpoint%22:%22https://:portfolio.assembla.com%22,%22icon%22:%22icon-assembla%22,%22name%22:%22Assembla%22,%22paths%22:%7B%22branch%22:%22/spaces/:owner/:repo/source/:branch?type=branch%22,%22commit%22:%22/spaces/:owner/:repo/commits/:commit%22,%22file%22:%22/spaces/:owner/:repo/source/:branch/:file%22,%22issue%22:%22/spaces/:owner/tickets/:issue%22,%22profile%22:%22/spaces/:owner%22,%22repo%22:%22/spaces/:owner/:repo/source%22,%22tag%22:%22/spaces/:owner/:repo/source/:tag?type=tag%22%7D,%22vocabulary%22:%7B%22organization%22:%22Portfolio%22,%22pullRequest%22:%22Merge%20Request%22%7D%7D,%22bitbucket%22:%7B%22endpoint%22:%22https://bitbucket.org%22,%22icon%22:%22icon-bitbucket%22,%22name%22:%22Bitbucket%22,%22paths%22:%7B%22branch%22:%22/:owner/:repo/src/:branch%22,%22commit%22:%22/:owner/:repo/commits/:commit%22,%22file%22:%22/:owner/:repo/src/:branch/:file%22,%22issue%22:%22/:owner/:repo/issues/:issue%22,%22profile%22:%22/:owner%22,%22repo%22:%22/:owner/:repo%22,%22tag%22:%22/:owner/:repo/src/:tag%22%7D,%22vocabulary%22:%7B%22organization%22:%22Organization%22,%22pullRequest%22:%22Pull%20Request%22%7D%7D,%22github%22:%7B%22endpoint%22:%22https://github.com%22,%22icon%22:%22icon-repooctocat%22,%22name%22:%22GitHub%22,%22paths%22:%7B%22branch%22:%22/:owner/:repo/tree/:branch%22,%22commit%22:%22/:owner/:repo/commit/:commit%22,%22file%22:%22/:owner/:repo/blob/:branch/:file%22,%22issue%22:%22/:owner/:repo/issues/:issue%22,%22profile%22:%22/:owner%22,%22repo%22:%22/:owner/:repo%22,%22tag%22:%22/:owner/:repo/releases/tag/:tag%22%7D,%22vocabulary%22:%7B%22organization%22:%22Organization%22,%22pullRequest%22:%22Pull%20Request%22%7D%7D%7D,%22plans%22:[%7B%22builds%22:1,%22price%22:6900,%22name%22:%22Bootstrap%22,%22period%22:%22monthly%22,%22currency%22:%22USD%22,%22description%22:%22Ideal%20for%20hobby%20projects%22,%22isEnabled%22:true,%22isDefault%22:false,%22monthlyPrice%22:6900,%22monthlyPriceRounded%22:69%7D,%7B%22builds%22:2,%22price%22:12900,%22name%22:%22Startup%22,%22period%22:%22monthly%22,%22currency%22:%22USD%22,%22description%22:%22Best%20for%20small%20teams%22,%22isEnabled%22:true,%22isDefault%22:true,%22monthlyPrice%22:12900,%22monthlyPriceRounded%22:129%7D,%7B%22builds%22:5,%22price%22:24900,%22name%22:%22Small%20Business%22,%22period%22:%22monthly%22,%22currency%22:%22USD%22,%22description%22:%22Great%20for%20growing%20teams%22,%22isEnabled%22:true,%22isDefault%22:false,%22monthlyPrice%22:24900,%22monthlyPriceRounded%22:249%7D,%7B%22builds%22:10,%22price%22:48900,%22name%22:%22Premium%22,%22period%22:%22monthly%22,%22currency%22:%22USD%22,%22description%22:%22Perfect%20for%20larger%20teams%22,%22isEnabled%22:true,%22isDefault%22:false,%22monthlyPrice%22:48900,%22monthlyPriceRounded%22:489%7D,%7B%22builds%22:1,%22price%22:75900,%22name%22:%22Bootstrap%22,%22period%22:%22annual%22,%22currency%22:%22USD%22,%22description%22:%22Ideal%20for%20hobby%20projects%22,%22isEnabled%22:true,%22isDefault%22:false,%22monthlyPrice%22:6325,%22monthlyPriceRounded%22:63%7D,%7B%22builds%22:2,%22price%22:141900,%22name%22:%22Startup%22,%22period%22:%22annual%22,%22currency%22:%22USD%22,%22description%22:%22Best%20for%20small%20teams%22,%22isEnabled%22:true,%22isDefault%22:true,%22monthlyPrice%22:11825,%22monthlyPriceRounded%22:118%7D,%7B%22builds%22:5,%22price%22:273900,%22name%22:%22Small%20Business%22,%22period%22:%22annual%22,%22currency%22:%22USD%22,%22description%22:%22Great%20for%20growing%20teams%22,%22isEnabled%22:true,%22isDefault%22:false,%22monthlyPrice%22:22825,%22monthlyPriceRounded%22:228%7D,%7B%22builds%22:10,%22price%22:537900,%22name%22:%22Premium%22,%22period%22:%22annual%22,%22currency%22:%22USD%22,%22description%22:%22Perfect%20for%20larger%20teams%22,%22isEnabled%22:true,%22isDefault%22:false,%22monthlyPrice%22:44825,%22monthlyPriceRounded%22:448%7D],%22screens%22:%7B%22base%22:%7B%22min%22:0,%22units%22:%22px%22,%22prefix%22:%22%22%7D,%22sm%22:%7B%22min%22:640,%22units%22:%22px%22,%22prefix%22:%22sm%22%7D,%22md%22:%7B%22min%22:768,%22units%22:%22px%22,%22prefix%22:%22md%22%7D,%22lg%22:%7B%22min%22:1024,%22units%22:%22px%22,%22prefix%22:%22lg%22%7D,%22xl%22:%7B%22min%22:1280,%22units%22:%22px%22,%22prefix%22:%22xl%22%7D%7D,%22EmberENV%22:%7B%22FEATURES%22:%7B%7D,%22EXTEND_PROTOTYPES%22:%7B%22Date%22:false%7D,%22_JQUERY_INTEGRATION%22:true%7D,%22APP%22:%7B%22appVersion%22:%222.0.1%22,%22name%22:%22travis%22,%22version%22:%220.0.1%22%7D,%22apiEndpoint%22:%22https://api.travis-ci.com%22,%22pusher%22:%7B%22key%22:%2259236bc0716a551eab40%22,%22host%22:%22ws.pusherapp.com%22,%22debug%22:false,%22channelPrefix%22:%22private-%22,%22encrypted%22:true%7D,%22intercom%22:%7B%22appId%22:%22dtjzv6xw%22,%22enabled%22:true,%22userProperties%22:%7B%22createdAtProp%22:%22createdAt%22,%22emailProp%22:%22email%22,%22nameProp%22:%22name%22,%22userHashProp%22:%22hash%22,%22userIdProp%22:%22id%22%7D%7D,%22urls%22:%7B%22about%22:%22https://about.travis-ci.com%22,%22bestpracticessecurity%22:%22https://docs.travis-ci.com/user/best-practices-security%23recommendations-on-how-to-avoid-leaking-secrets-to-build-logs%22,%22blog%22:%22https://blog.travis-ci.com%22,%22buildMatrix%22:%22https://docs.travis-ci.com/user/build-matrix/%22,%22buildConfigValidation%22:%22https://docs.travis-ci.com/user/build-config-validation/%22,%22changelog%22:%22https://changelog.travis-ci.com%22,%22community%22:%22https://travis-ci.community%22,%22communityEarlyReleases%22:%22https://travis-ci.community/c/early-releases%22,%22dashboard%22:%22https://travis-ci.com/dashboard%22,%22docker%22:%22https://docs.travis-ci.com/user/docker/%22,%22docs%22:%22https://docs.travis-ci.com%22,%22gettingStarted%22:%22https://docs.travis-ci.com/user/getting-started/%23to-get-started-with-travis-ci%22,%22education%22:%22https://education.travis-ci.com%22,%22emailSupport%22:%22mailto:[email protected]%22,%22enterprise%22:%22https://enterprise.travis-ci.com%22,%22imprint%22:%22https://docs.travis-ci.com/imprint.html%22,%22jobs%22:%22https://travisci.workable.com/%22,%22multiOS%22:%22https://docs.travis-ci.com/user/multi-os/%22,%22node%22:%22https://docs.travis-ci.com/user/languages/javascript-with-nodejs/%22,%22noRun%22:%22https://docs.travis-ci.com/user/common-build-problems/%23i-pushed-a-commit-and-cant-fin%22,%22plans%22:%22https://travis-ci.com/plans%22,%22privacy%22:%22https://docs.travis-ci.com/legal/privacy-policy%22,%22security%22:%22https://docs.travis-ci.com/legal/security%22,%22status%22:%22https://www.traviscistatus.com/%22,%22support%22:%22mailto:[email protected]%22,%22terms%22:%22https://docs.travis-ci.com/legal/terms-of-service/%22,%22tutorial%22:%22https://docs.travis-ci.com/user/tutorial/%22,%22twitter%22:%22https://twitter.com/travisci%22%7D,%22endpoints%22:%7B%22sshKey%22:%22true%22,%22caches%22:%22true%22%7D,%22githubApps%22:%7B%22appName%22:%22travis-ci%22,%22migrationRepositoryCountLimit%22:50%7D,%22timing%22:%7B%22syncingPageRedirectionTime%22:5000%7D,%22intervals%22:%7B%22updateTimes%22:1000,%22branchCreatedSyncDelay%22:2000,%22searchDebounceRate%22:500,%22triggerBuildRequestDelay%22:3000,%22fetchRecordsForPusherUpdatesThrottle%22:1000,%22repositoryFilteringDebounceRate%22:200,%22syncingPolling%22:3000,%22githubAppsInstallationPolling%22:4000%7D,%22githubOrgsOauthAccessSettingsUrl%22:%22https://github.com/settings/connections/applications/88c5b97de2dbfc50f3ac%22,%22apiTraceEndpoint%22:%22https://console.cloud.google.com/traces/traces?project=eco-emissary-99515&organizationId=928883094116&q=%252Brequest_id:%22,%22ajaxPolling%22:false,%22logLimit%22:100000,%22emojiPrepend%22:%22%22,%22statusPageStatusUrl%22:%22https://pnpcptp8xh9k.statuspage.io/api/v2/status.json%22,%22zendesk%22:%7B%22apiHost%22:%22https://travisci.zendesk.com%22,%22createRequestEndpoint%22:%22/api/v2/requests.json%22%7D,%22moment%22:%7B%22includeTimezone%22:%22subset%22%7D,%22stripeOptions%22:%7B%22hidePostalCode%22:true,%22style%22:%7B%22base%22:%7B%22fontStyle%22:%22Source%20Sans%20Pro%22,%22fontSize%22:%2215px%22,%22color%22:%22%23666%22,%22::placeholder%22:%7B%22color%22:%22%23aaa%22%7D%7D,%22invalid%22:%7B%22color%22:%22red%22,%22iconColor%22:%22red%22%7D%7D%7D,%22metricsAdapters%22:[%7B%22name%22:%22GoogleAnalytics%22,%22environments%22:[%22development%22,%22production%22],%22config%22:%7B%22id%22:%22UA-24868285-5%22,%22debug%22:false,%22trace%22:false,%22sendHitTask%22:true%7D%7D,%7B%22name%22:%22GoogleTagManager%22,%22config%22:%7B%22id%22:%22GTM-N3RT7TD%22%7D%7D],%22featureFlags%22:%7B%22repository-filtering%22:true,%22debug-logging%22:false,%22landing-page-cta%22:true,%22show-running-jobs-in-sidebar%22:false,%22debug-builds%22:false,%22broadcasts%22:true,%22beta-features%22:true,%22github-apps%22:true,%22enable-assembla-login%22:false,%22enable-bitbucket-login%22:false,%22pro-version%22:true%7D,%22pro%22:true,%22pagination%22:%7B%22dashboardReposPerPage%22:25,%22profileReposPerPage%22:25%7D,%22stripe%22:%7B%22publishableKey%22:%22pk_live_ch2y6Gvzwy9UPstMhmmldpmr%22,%22lazyLoad%22:true%7D,%22sentry%22:%7B%22dsn%22:%22https://[email protected]/75334%22,%22whitelistUrls%22:[%7B%7D]%7D,%22pagesEndpoint%22:%22https://travis-ci.com/account/subscription%22,%22billingEndpoint%22:%22https://travis-ci.com%22,%22marketplaceEndpoint%22:%22https://github.com/marketplace/travis-ci/%22,%22userlike%22:true,%22publicMode%22:true,%22release%22:%22f523f7ea9%22,%22ember-cli-mirage%22:%7B%22usingProxy%22:false,%22useDefaultPassthroughs%22:true%7D,%22ember-concurrency-scroll%22:%7B%22overrides%22:%7B%7D%7D,%22exportApplicationGlobal%22:false,%22ember-modal-dialog%22:%7B%22hasLiquidWormhole%22:%222.1.5%22%7D,%22sourceEndpoint%22:%22https://github.com%22,%22gaCode%22:%22UA-24868285-5%22%7D" />
<meta name="theme-color" content="#fff">
<link rel="apple-touch-icon" href="https://cdn.travis-ci.com/favicon-b4e438ec85b9ae88d26b49538bc4e5ce.png" sizes="256x256">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-title" content="Travis CI">
<meta name="apple-mobile-web-app-status-bar-style" content="default">

    <link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700" rel="stylesheet" type="text/css">
    <link href="https://fonts.googleapis.com/css?family=Cousine:400,400i,700,700i" rel="stylesheet" type="text/css">
    <link integrity="" rel="stylesheet" href="https://cdn.travis-ci.com/assets/vendor-e36b93c320e0a9d37c424ee236e2a8ae.css">
    <link integrity="" rel="stylesheet" href="https://cdn.travis-ci.com/assets/travis-022b14625d5ff8848d2109d3c9c4d124.css">
    <link rel="mask-icon" href="https://cdn.travis-ci.com/images/favicon-c566132d45ab1a9bcae64d8d90e4378a.svg" color="black">


  </head>
  <body>
    <noscript>
      <div style="width: 60%; margin: auto;">
        <img src="/images/logos/TravisCI-Mascot-1.png" alt="Travis CI mascot" width="200" style="float: left; margin: 1em 3em;">
        <div>
          <h1>Hey there!</h1>
          <p>Looks like you have JavaScript disabled.</p>
          <p>The Travis CI webclient needs JavaScript to work properly.</p>
          <h2>Please enable JavaScript to get the best Travis CI experience.</h2>
          <h3>Thank you!</h3>
        </div>
      </div>
    </noscript>


    <script src="https://cdn.travis-ci.com/assets/vendor-7696e57cb1e8cf557a7b731f0bc6b24c.js"></script>
    <script src="https://cdn.travis-ci.com/assets/travis-0957b38c9ea8222154a963128998a7f5.js"></script>

    <div id="ember-basic-dropdown-wormhole"></div>

  </body>
</html>

@probonopd
Copy link
Author

Hi @shuheiktgw this response looks something designed for humans, not like an API response. What does this mean?

@shuheiktgw
Copy link
Owner

As I wrote in #75, the endpoint does not work correctly anymore. Also, it's actually not an v3 endpoint, I've decided to remove Authentication.UsingGithubToken method. Thanks for reporting the issue!

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

No branches or pull requests

2 participants