How to use osm-auth - 10 common examples

To help you get started, we’ve selected a few osm-auth examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github openstreetmap / iD / modules / services / notes.js View on Github external
utilRebind,
    utilIdleWorker
} from '../util';

import {
    osmNote
} from '../osm';
import { actionRestrictTurn } from '../actions';

var urlroot = 'https://api.openstreetmap.org',
    _notesCache,
    dispatch = d3_dispatch('loadedNotes', 'loading'),
    tileZoom = 14;

// TODO: complete authentication
var oauth = osmAuth({
    url: urlroot,
    oauth_consumer_key: '',
    oauth_secret: '',
    loading: authLoading,
    done: authDone
});

function authLoading() {
    dispatch.call('authLoading');
}

function authDone() {
    dispatch.call('authDone');
}

function authenticated() {
github osmlab / to-fix / src / api / osm.js View on Github external
import osmAuth from 'osm-auth';
import {
  OAUTH_CONSUMER_KEY,
  OAUTH_CONSUMER_SECRET,
} from '../config';

const auth = osmAuth({
  oauth_consumer_key: OAUTH_CONSUMER_KEY,
  oauth_secret: OAUTH_CONSUMER_SECRET,
  auto: false,
  landing: 'oauth-complete.html',
  url: 'https://www.openstreetmap.org',
});

export const isAuthenticated = () => auth.authenticated();

export const login = () => {
  return new Promise((resolve, reject) => {
    auth.authenticate((error, oauth) => {
      if (error) reject(error);
      resolve(oauth);
    });
  });
github tyrasd / overpass-turbo / js / sync-with-osm.js View on Github external
import osmAuth from "osm-auth";
import configs from "./configs";

var enabled =
  configs.osmAuth &&
  configs.osmAuth.oauth_consumer_key &&
  configs.osmAuth.oauth_secret;

var auth;
if (enabled) auth = osmAuth(configs.osmAuth);

export default {
  enabled: enabled,
  load: function(callback) {
    if (!auth.authenticated()) {
      auth.authenticate(function(err) {
        //check err param exists
        if (err) return callback(err);
        loadQueries(callback);
      });
    } else {
      loadQueries(callback);
    }
  },
  save: function(query, callback) {
    if (!auth.authenticated()) {
github mapcontrib / mapcontrib / public / js / view / contribute / delete / confirmationModal.js View on Github external
this._theme = this.options.theme;
    this._iDPresetsHelper = this.options.iDPresetsHelper;
    this._nonOsmData = this.options.nonOsmData;
    this._osmCache = this.options.osmCache;
    this._user = this.options.user;
    this._layer = this.options.layer;
    this._layerModel = this.options.layerModel;

    this._osmCacheModel = this._osmCache.findWhere({
      themeFragment: this._theme.get('fragment'),
      osmId: this.options.osmId,
      osmType: this.options.osmType
    });

    this._osmEdit = new OsmEditHelper(
      osmAuth({
        url: this._config.oauthEndPoint,
        oauth_consumer_key: this._config.oauthConsumerKey,
        oauth_secret: this._config.oauthSecret,
        oauth_token: this._user.get('token'),
        oauth_token_secret: this._user.get('tokenSecret')
      })
    );

    this._osmEdit.setType(this.options.osmType);
    this._osmEdit.setId(this.options.osmId);
  },
github mapcontrib / mapcontrib / public / js / view / contribute / add / formColumn.js View on Github external
this._radio = Wreqr.radio.channel('global');
    this._config = this.options.config;
    this._theme = this.options.theme;
    this._iDPresetsHelper = this.options.iDPresetsHelper;
    this._nonOsmData = this.options.nonOsmData;
    this._osmCache = this.options.osmCache;
    this._user = this.options.user;
    this._center = this.options.center;

    this._presetsHelper = new PresetsHelper(
      this._theme.get('tags'),
      this._iDPresetsHelper
    );

    this._osmEdit = new OsmEditHelper(
      osmAuth({
        url: this._config.oauthEndPoint,
        oauth_consumer_key: this._config.oauthConsumerKey,
        oauth_secret: this._config.oauthSecret,
        oauth_token: this._user.get('token'),
        oauth_token_secret: this._user.get('tokenSecret')
      })
    );
  },
github openstreetmap / iD / modules / services / osm.js View on Github external
osmRelation,
    osmWay
} from '../osm';

import { utilRebind, utilIdleWorker } from '../util';


var dispatch = d3_dispatch('authLoading', 'authDone', 'change', 'loading', 'loaded'),
    urlroot = 'https://www.openstreetmap.org',
    blacklists = ['.*\.google(apis)?\..*/(vt|kh)[\?/].*([xyz]=.*){3}.*'],
    inflight = {},
    loadedTiles = {},
    entityCache = {},
    connectionId = 1,
    tileZoom = 16,
    oauth = osmAuth({
        url: urlroot,
        oauth_consumer_key: '5A043yRSEugj4DJ5TljuapfnrflWDte8jTOcWLlT',
        oauth_secret: 'aB3jKq1TRsCOUrfOIZ6oQMEDmv2ptV76PA54NGLL',
        loading: authLoading,
        done: authDone
    }),
    rateLimitError,
    userChangesets,
    userDetails,
    off;


function authLoading() {
    dispatch.call('authLoading');
}
github openstreetmap / iD / modules / services / osm.js View on Github external
import { dispatch as d3_dispatch } from 'd3-dispatch';
import { xml as d3_xml } from 'd3-fetch';

import osmAuth from 'osm-auth';
import RBush from 'rbush';

import { JXON } from '../util/jxon';
import { geoExtent, geoRawMercator, geoVecAdd, geoZoomToScale } from '../geo';
import { osmEntity, osmNode, osmNote, osmRelation, osmWay } from '../osm';
import { utilArrayChunk, utilArrayGroupBy, utilArrayUniq, utilRebind, utilTiler, utilQsString } from '../util';


var tiler = utilTiler();
var dispatch = d3_dispatch('apiStatusChange', 'authLoading', 'authDone', 'change', 'loading', 'loaded', 'loadedNotes');
var urlroot = 'https://www.openstreetmap.org';
var oauth = osmAuth({
    url: urlroot,
    oauth_consumer_key: '5A043yRSEugj4DJ5TljuapfnrflWDte8jTOcWLlT',
    oauth_secret: 'aB3jKq1TRsCOUrfOIZ6oQMEDmv2ptV76PA54NGLL',
    loading: authLoading,
    done: authDone
});

var _blacklists = ['.*\.google(apis)?\..*/(vt|kh)[\?/].*([xyz]=.*){3}.*'];
var _tileCache = { toLoad: {}, loaded: {}, inflight: {}, seen: {}, rtree: new RBush() };
var _noteCache = { toLoad: {}, loaded: {}, inflight: {}, inflightPost: {}, note: {}, closed: {}, rtree: new RBush() };
var _userCache = { toLoad: {}, user: {} };
var _cachedApiStatus;
var _changeset = {};

var _deferred = new Set();
var _connectionID = 1;
github mapcontrib / mapcontrib / public / js / view / contribute / edit / formColumn.js View on Github external
this._iDPresetsHelper = this.options.iDPresetsHelper;
    this._nonOsmData = this.options.nonOsmData;
    this._osmCache = this.options.osmCache;
    this._user = this.options.user;
    this._layer = this.options.layer;
    this._layerModel = this.options.layerModel;

    this._contributionSent = false;

    this._presetsHelper = new PresetsHelper(
      this._theme.get('tags'),
      this._iDPresetsHelper
    );

    this._osmEdit = new OsmEditHelper(
      osmAuth({
        url: this._config.oauthEndPoint,
        oauth_consumer_key: this._config.oauthConsumerKey,
        oauth_secret: this._config.oauthSecret,
        oauth_token: this._user.get('token'),
        oauth_token_secret: this._user.get('tokenSecret')
      })
    );

    this._osmEdit.setType(this.options.osmType);
    this._osmEdit.setId(this.options.osmId);
  },
github mapcontrib / mapcontrib / public / js / view / contribute / edit / formColumn.js View on Github external
this._radio = Wreqr.radio.channel('global');
        this._map = this._radio.reqres.request('map');
        this._config = this.options.config;
        this._theme = this.options.theme;
        this._iDPresetsHelper = this.options.iDPresetsHelper;
        this._nonOsmData = this.options.nonOsmData;
        this._osmCache = this.options.osmCache;
        this._user = this.options.user;
        this._layer = this.options.layer;
        this._layer = this.options.layer;
        this._layerModel = this.options.layerModel;

        this._contributionSent = false;

        this._osmEdit = new OsmEditHelper(
            osmAuth({
                url: this._config.oauthEndPoint,
                oauth_consumer_key: this._config.oauthConsumerKey,
                oauth_secret: this._config.oauthSecret,
                oauth_token: this._user.get('token'),
                oauth_token_secret: this._user.get('tokenSecret'),
            })
        );

        this._osmEdit.setType( this.options.osmType );
        this._osmEdit.setId( this.options.osmId );
    },
github mapcontrib / mapcontrib / public / js / view / admin / setting / cacheModification / tagForm.js View on Github external
constructor(props) {
    super(props);

    const state = {};

    Object.keys(props.diffObject.tags).forEach(
      key => (state[key] = props.diffObject.tags[key].modified)
    );

    this.state = state;

    this._osmEdit = new OsmEditHelper(
      osmAuth({
        url: this.props.oauthEndPoint,
        oauth_consumer_key: this.props.oauthConsumerKey,
        oauth_secret: this.props.oauthSecret,
        oauth_token: this.props.user.get('token'),
        oauth_token_secret: this.props.user.get('tokenSecret')
      })
    );

    this._osmEdit.setType(this.props.feature.properties.type);
    this._osmEdit.setId(this.props.feature.properties.id);
  }

osm-auth

A usable example of JavaScript OAuth 2.0 with OpenStreetMap

ISC
Latest version published 3 months ago

Package Health Score

73 / 100
Full package analysis

Popular osm-auth functions