text stringlengths 34 4.22k | embeddings listlengths 768 768 |
|---|---|
::: tip
Make sure you read the [introduction to .NET](/dev/dotnet) before you dive in here! The most important sections you need to cover first are: | [
-1.1221576929092407,
-0.6545504927635193,
0.15942485630512238,
0.03176378831267357,
-0.5661558508872986,
0.7094968557357788,
0.5261232256889343,
-0.4499831795692444,
0.6587446331977844,
0.13174939155578613,
-0.2717227041721344,
-0.47384923696517944,
-0.3597736358642578,
-0.1797011941671371... |
As you know, Speckle data is structured according to the conventions of the host application, domain or mental model of the developer. There is no single canonical way in which data is structured! | [
-0.22793535888195038,
-0.6210981607437134,
0.4941736161708832,
0.4864256978034973,
-0.32819539308547974,
0.07106220722198486,
0.1781042367219925,
-0.37410688400268555,
0.7374842762947083,
1.0064589977264404,
-0.4860646724700928,
-0.8307605981826782,
-0.2357042282819748,
-0.1814493387937545... |
Generally, working with structured data is a bit more difficult, as you need to parse the "graph", or the tree that describes its structure. Nevertheless, this doesn't need to be so! What if we could access all the data inside a given commit and treat it just as any other list? Well, it's actually super easy! | [
0.08256399631500244,
-1.0044231414794922,
0.8609516024589539,
-0.2258882224559784,
-0.309345543384552,
0.2167278528213501,
-0.10323012620210648,
-0.700217604637146,
0.2156638354063034,
0.3544641435146332,
-0.8277190923690796,
-0.7700120806694031,
-0.5260905623435974,
0.15611211955547333,
... |
The extension method below flattens any `Base` object into its constituent parts: it returns a list of all its sub-`Base`s. **Simply add this to your project somewhere and you're good to go.** | [
-0.6907806396484375,
-0.5803492069244385,
0.004570931661874056,
-0.42225348949432373,
-0.5735138058662415,
0.267191082239151,
-0.2719898521900177,
0.08338329941034317,
0.635749876499176,
0.6162620782852173,
-0.8380923271179199,
-1.035427212715149,
-0.5061278343200684,
-0.2708434760570526,
... |
Once we test this a bit more, we're probably going to add it to our Core SDK - so keep an eye out! | [
-0.9245564937591553,
-0.11058289557695389,
0.38631871342658997,
0.40555793046951294,
-0.361868292093277,
-0.29846394062042236,
0.5041781663894653,
-0.6854907870292664,
0.36888742446899414,
0.5789862275123596,
-0.9803260564804077,
-0.5016168355941772,
0.022251741960644722,
-0.20023933053016... |
public static class Extensions
{
// Flattens a base object into all its constituent parts.
public static IEnumerable<Base> Flatten(this Base obj)
{
yield return obj; | [
-0.5808952450752258,
-0.2987470328807831,
-0.18656927347183228,
-0.071446992456913,
-0.24395261704921722,
0.1412608027458191,
-0.07148611545562744,
-0.4670619070529938,
0.1255923956632614,
0.6621361374855042,
-0.5735397338867188,
-0.20775245130062103,
-0.10862017422914505,
0.01608825847506... |
var props = obj.GetDynamicMemberNames();
foreach (var prop in props)
{
var value = obj[prop];
if (value == null) continue; | [
-0.040468424558639526,
-0.3197799324989319,
0.4831668734550476,
-0.3480510711669922,
-0.5688010454177856,
0.7949169278144836,
0.19802866876125336,
0.10607261210680008,
0.49867627024650574,
1.244863748550415,
-0.674939751625061,
-0.46929723024368286,
-0.8861204981803894,
-0.3616665899753570... |
if (value is Base b)
{
var nested = b.Flatten();
foreach (var child in nested) yield return child;
} | [
0.17727535963058472,
-0.28055357933044434,
-0.11314164847135544,
0.14846128225326538,
-0.4828800857067108,
0.5866183638572693,
-0.2044980376958847,
0.01997951790690422,
0.018609432503581047,
0.6116635203361511,
-0.755030632019043,
-0.8991771340370178,
-0.8585329055786133,
-0.51482707262039... |
if (value is IDictionary dict)
{
foreach (var dictValue in dict.Values)
{
if (dictValue is Base lb)
{
foreach (var lbChild in lb.Flatten()) yield return lbChild;
}
}
} | [
-0.138417050242424,
-0.336856871843338,
-0.01237448863685131,
0.07687027752399445,
-0.5466201305389404,
0.4760158956050873,
-0.2576373219490051,
0.20740824937820435,
0.37685710191726685,
0.5832527279853821,
-0.6755736470222473,
-0.6748975515365601,
-0.6365107297897339,
-0.1968294382095337,... |
if (value is IEnumerable enumerable)
{
foreach (var listValue in enumerable)
{
if (listValue is Base lb)
{
foreach (var lbChild in lb.Flatten()) yield return lbChild;
}
}
}
}
}
} | [
-0.22612637281417847,
-0.05680735036730766,
-0.46853339672088623,
0.16994963586330414,
-0.07587596774101257,
0.4600212574005127,
0.0474124550819397,
-0.09061063826084137,
0.09027764201164246,
0.8706109523773193,
-0.46984121203422546,
-0.34128597378730774,
-0.5864341855049133,
-0.1608902961... |
Now that we have our flattening method in place, what can we do? Well - quite a lot! We can now use the power of LINQ to do complex queries on our dataset. For example, let's assume we want to get **all the timber walls** from a given building. How should we do that? Easy: | [
-0.6707361340522766,
-0.8485864400863647,
0.22171266376972198,
-0.08593600243330002,
-0.11350177228450775,
0.20285533368587494,
-0.07629550248384476,
-0.5801784992218018,
0.12803970277309418,
0.9111613035202026,
-0.16392268240451813,
-0.2911643087863922,
-0.316364049911499,
-0.330344587564... |
// Receive a revit commit (note: you will need a local account on app.speckle.systems for this to work!)
var data = Helpers.Receive("https://speckle.xyz/streams/0d3cb7cb52/commits/681cdd572c").Result;
var flatData = data.Flatten().ToList(); | [
-0.2816719114780426,
0.2651338577270508,
0.08773083239793777,
-0.22735433280467987,
-0.29194188117980957,
0.4264794588088989,
0.02485756203532219,
-0.1682528555393219,
0.9969061017036438,
1.009806752204895,
-0.6720264554023743,
-0.5240105986595154,
-0.5359538793563843,
-0.20561176538467407... |
var timberWalls = flatData.FindAll(obj => obj is Objects.BuiltElements.Revit.RevitWall wall && wall.type == "Wall - Timber Clad"); | [
-0.17339059710502625,
-0.7598956227302551,
-0.04863898456096649,
-0.0625765323638916,
0.1995561420917511,
0.5430173873901367,
0.37271732091903687,
0.2009112536907196,
0.2680193781852722,
0.7312722206115723,
-0.4595746099948883,
-1.0117170810699463,
-0.3839024603366852,
-0.40200063586235046... |
Check out the [actual filtered timber walls here, in 3D](https://speckle.xyz/streams/0d3cb7cb52/commits/681cdd572c?filter=%7B%22ghostOthers%22%3Atrue,%22filterBy%22%3A%7B%22type%22%3A%5B%22Wall%20-%20Timber%20Clad%22%5D%7D,%22colorBy%22%3Anull%7D&c=%5B8.38909,-14.62227,21.72508,19.02341,-4.21317,7.28914,0,1%5D)! | [
-0.6671214699745178,
-1.377046823501587,
0.6447840929031372,
0.34513717889785767,
-0.5115018486976624,
0.0693293884396553,
0.5670119524002075,
-0.4832870364189148,
0.5627799034118652,
0.985020101070404,
-0.5634954571723938,
-1.059865117073059,
-0.25481048226356506,
0.07499240338802338,
-... |
Having fun? Let's try a couple more examples! Here's a query that will return all the **windows**: | [
-0.10960186272859573,
-0.9522606134414673,
0.8360351324081421,
0.25886887311935425,
-0.47156277298927307,
-0.05380439758300781,
0.20198692381381989,
-0.007677000481635332,
0.4194428622722626,
0.6734760403633118,
-1.0161470174789429,
-0.9030781984329224,
-0.5404741168022156,
-0.394988000392... |
// Note: to get only the unique levels, we need to de-duplicate them.
var levels = flatData.FindAll(obj => obj is Objects.BuiltElements.Level).Cast<Objects.BuiltElements.Level>().GroupBy(level => level.name).Select(g => g.First()).ToList(); | [
-0.19046024978160858,
-0.24663378298282623,
-0.0768197551369667,
-0.09720310568809509,
0.06232576072216034,
0.7085281610488892,
0.46598148345947266,
-0.027059806510806084,
0.13072419166564941,
0.597690224647522,
-0.632744550704956,
-1.246415376663208,
-0.8262071013450623,
-0.14599746465682... |
For a more complex query, let's try to create a summary of all the elements on each level. Here's how to achieve this with the power of LINQ: | [
-0.46867141127586365,
-0.4407089650630951,
0.6572281718254089,
-0.054968565702438354,
0.12294433265924454,
0.3351970613002777,
0.6248587369918823,
-0.3116975426673889,
0.5882067680358887,
0.649334728717804,
-0.5364834666252136,
-0.595639705657959,
-0.6514700055122375,
-0.18290531635284424,... |
var elementsByLevel = flatData.FindAll(obj => obj["level"] != null).GroupBy(obj => ((Base)obj["level"])["name"]);
foreach(var grouping in elementsByLevel) {
Console.WriteLine($"On level {grouping.Key} there are {grouping.Count()} elements.");
} | [
-0.17958442866802216,
-0.2505881190299988,
0.5007106065750122,
-0.28156471252441406,
0.07644879072904587,
0.87830650806427,
0.5133727788925171,
0.1591750532388687,
0.38629502058029175,
0.4189639985561371,
-0.41177859902381897,
-1.585634708404541,
-0.770672082901001,
-0.13588228821754456,
... |
```
On level Level 1 there are 74 elements.
On level Roof Line there are 1 elements.
On level Ceiling there are 4 elements.
On level Level 2 there are 64 elements.
On level Level 1 Living Rm. there are 14 elements.
On level Foundation there are 31 elements.
``` | [
-0.2680271565914154,
0.07736624032258987,
0.09514956921339035,
0.6156238317489624,
0.25216859579086304,
0.5771815180778503,
0.8885864019393921,
-0.24541935324668884,
-0.2324131429195404,
0.46378087997436523,
-0.722210705280304,
-0.5969544053077698,
-0.3182013928890228,
0.148268923163414,
... |
Both structured data and flattened data have advantages and disadvantages. The latter lends itself for ETL workflows and various classification based exercises, whereas the former allows for a better model. Dealing with structured data doesn't mean that we can't flatten it and benefit from all processing ease of flattened data. You can use this as a basis for quite a few automation exercises, such as:
- automatically compiling bills of materials
- checking model quality (ie, why are there two Level 1s, `Level 1` and `Level 1 Living Rm` in that model?)
- creating custom schedules
- and more! | [
-0.04568631947040558,
-0.8946374654769897,
0.4053625464439392,
0.16793285310268402,
-0.07114354521036148,
-0.06056715548038483,
-0.15889379382133484,
-0.5985404253005981,
-0.04828008636832237,
0.36511772871017456,
-0.36624008417129517,
-0.4914602041244507,
-0.17865902185440063,
0.196504056... |
Welcome to the **Speckle Developer Docs** - a single source of documentation on everything Speckle!
If you're looking for info on how to _use_ Speckle, check our [user guide](/). | [
-0.7324498295783997,
-0.4897148013114929,
0.27068251371383667,
0.5300108790397644,
-0.5645455121994019,
0.15478157997131348,
0.1700507551431656,
-0.018601153045892715,
0.6165083050727844,
0.8356849551200867,
-0.42985236644744873,
-0.9246057868003845,
-0.2951265275478363,
-0.255062550306320... |
> Speckle is the open source data platform for architecture, engineering, and construction. It liberates your data from proprietary file formats and closed source software and puts it back into your hands. | [
-0.3926064074039459,
-0.3210182785987854,
0.27995041012763977,
0.5331804156303406,
-0.39084044098854065,
0.2600892186164856,
0.22686867415905,
-0.5146402716636658,
0.5528877973556519,
0.8474719524383545,
-0.024498026818037033,
-0.6989001631736755,
-0.27289262413978577,
-0.7476022243499756,... |
This part of our docs is for any developer planning to extend, integrate or improve Speckle. We'll walk you through the main concepts behind our tech and guide you through fun tasks such as [writing your own connector](/dev/connectors-dev) or [writing custom Speckle apps](/dev/apps). | [
-0.9382521510124207,
-0.2429477423429489,
0.5904978513717651,
0.16077376902103424,
-0.5123632550239563,
0.3080853223800659,
0.32372453808784485,
-0.3698866665363312,
0.9853195548057556,
0.6560488343238831,
-0.739025890827179,
-0.5103323459625244,
-0.046551987528800964,
-0.1333879679441452,... |
We hope to see the great things you'll do with our SDKs and APIs, let's go! | [
-0.4694342613220215,
0.14063221216201782,
0.9391491413116455,
0.3717198967933655,
-0.4408622086048126,
-0.23479487001895905,
0.37258437275886536,
-0.29944878816604614,
0.5794600248336792,
0.9960001707077026,
-0.7668803334236145,
-0.9059560298919678,
-0.3216531574726105,
-0.439382404088974,... |
We call Speckle a data platform but Speckle is also a set of connectors for AEC applications. There are Speckle kits, which are the base of our approach to interoperability. Then there are various Speckle apps - like the Speckle 3D viewer, the Speckle Web UI, the Speckle Server... | [
-0.7599912881851196,
-0.3421761691570282,
0.3587256371974945,
0.43208780884742737,
-0.1491645723581314,
0.8455682992935181,
0.5656719207763672,
-0.5957314372062683,
0.8424427509307861,
0.7541295886039734,
-0.42891615629196167,
-0.35915929079055786,
-0.02940208651125431,
0.00819237530231475... |
That's quite a lot to chew, but you're probably still asking yourself - **what is Speckle**? | [
-0.2908341586589813,
-0.8638384342193604,
0.42830413579940796,
0.22229592502117157,
-0.8022225499153137,
0.3274118900299072,
0.2632722556591034,
-0.5966667532920837,
1.4936145544052124,
0.5866856575012207,
-0.4320649802684784,
0.0517444983124733,
-0.5227402448654175,
-0.12947191298007965,
... |
> Ultimately, Speckle has two distinct parts: the developer platform, and the applications and products built on top of it. | [
-0.43994930386543274,
-0.14715301990509033,
0.45543697476387024,
0.923747181892395,
-0.18290244042873383,
0.9918593764305115,
0.1669507622718811,
-0.7630472779273987,
1.0759001970291138,
0.9707766175270081,
-0.3936045467853546,
-0.19238440692424774,
-0.2694578468799591,
-0.4363265931606293... |
So what's what? Simple: if an architect/engineer/AEC professional interacts with it, it's a Speckle **product** built on top of Speckle's **developer platform**. | [
-0.5755794048309326,
-0.3783324360847473,
0.4947378635406494,
0.5292526483535767,
-0.0399879589676857,
0.7885894775390625,
0.49320340156555176,
-1.0985702276229858,
1.040381669998169,
0.8146625757217407,
-0.3713700771331787,
-0.39626312255859375,
-0.330251008272171,
-0.30657413601875305,
... |
The developer platform consists of code that makes it easier for us (and you!) to build user-facing applications - either web-based or desktop-based. | [
-0.6679447889328003,
-0.2731388211250305,
0.21628153324127197,
0.7895054221153259,
0.21954242885112762,
0.6138047575950623,
-0.0027578268200159073,
-0.35479989647865295,
0.8359832763671875,
0.6020249724388123,
-0.5199763774871826,
-0.4797779619693756,
0.00863292533904314,
0.217509642243385... |
This section is about the platform, and not about the products. If you want to see how to use Speckle as an architect or engineer, check our [user guide](/). | [
-0.6768540740013123,
-0.48964980244636536,
0.31623515486717224,
0.5938491225242615,
-0.6866943836212158,
0.4349522590637207,
0.4600246846675873,
-0.42160525918006897,
0.7020168304443359,
0.7993137240409851,
-0.6171808242797852,
-0.7372844219207764,
-0.20403286814689636,
-0.1243005692958831... |
Our platform is made of many moving parts, the code for anything Speckle 2.0 onwards is hosted in our [GitHub specklesystems organization](https://github.com/specklesystems).
Here's a quick summary of the main repos you'll find there, please make sure to give them a star ⭐️ if you like what you see! | [
-0.4700779616832733,
0.11972800642251968,
0.4744209349155426,
0.34875303506851196,
-0.4435555338859558,
0.5080386996269226,
0.20833680033683777,
-0.553785502910614,
0.9532152414321899,
0.8279661536216736,
-0.5317708253860474,
-0.6020941734313965,
-0.1848941296339035,
-0.2985582947731018,
... |
[Speckle Server](https://github.com/specklesystems/speckle-server) contains all the web-based applications including the server backend, the frontend web application, and the 3D viewer. | [
-0.8728256225585938,
-0.20475967228412628,
0.6595701575279236,
0.5612199306488037,
-0.12879124283790588,
0.3660393953323364,
0.6801977157592773,
-0.3887372612953186,
0.9635388255119324,
0.7765575647354126,
-0.4693881869316101,
-0.5104317665100098,
0.11432094871997833,
-0.02015947550535202,... |
```text
└── speckle-server
├── server
├── frontend
└── viewer
``` | [
-0.6950362920761108,
-0.03608114272356033,
0.26834914088249207,
0.8231549859046936,
-0.8299936652183533,
0.2658972442150116,
0.08679743856191635,
-0.04499493166804314,
0.8221423029899597,
0.8150367736816406,
-0.4743832051753998,
-0.7103986740112305,
-0.5743234753608704,
0.24230124056339264... |
[Speckle Sharp](https://github.com/specklesystems/speckle-sharp) contains all the C# desktop components including the .NET SDK, the connectors (Rhino, Revit, Grasshopper, & Dynamo...), and Objects (our default interoperability kit). | [
-0.8337833285331726,
-0.2925339937210083,
0.29435303807258606,
0.17700855433940887,
-0.24688833951950073,
0.46708303689956665,
0.5255398750305176,
-0.5017518997192383,
0.6644394397735596,
0.5456225275993347,
-0.6884493827819824,
-0.624059796333313,
0.27384713292121887,
-0.2819077670574188,... |
```text
└── speckle-sharp
├── core
├── connector revit
├── connector rhino
├── connector dynamo
├── connector grasshopper
├── connector autocadcivil
├── desktopui
└── objects
├── objects
└── converters
├── revit
├── rhinogh
├── dynamo
└── autocadcivil
``` | [
-0.8923966884613037,
-0.3478465974330902,
0.0925537496805191,
0.5015286803245544,
-0.5237777829170227,
0.08909443020820618,
0.5654237866401672,
-0.043121594935655594,
0.12756213545799255,
0.728659987449646,
-1.0323759317398071,
-0.7420694231987,
-0.35333144664764404,
0.07700391858816147,
... |
To put it simply, Speckle Sharp is what you use to free your data from different models and desktop applications and Speckle Server is where you send all this data and interact with it in the browser. | [
-0.6794322729110718,
-0.7464451193809509,
0.07329044491052628,
0.05681432783603668,
-0.5456640720367432,
0.2712578773498535,
0.29348450899124146,
-0.6040208339691162,
0.6067543625831604,
0.6319716572761536,
-0.6003214120864868,
-0.1659778505563736,
0.13503488898277283,
-0.21059641242027283... |
[Speckle Py](https://github.com/specklesystems/speckle-py) is our Python SDK. Are you more of a pythonista than a .NET ninja? Have a play with it! | [
-0.30029892921447754,
-0.09270580857992172,
-0.0007936921319924295,
0.5325877666473389,
-0.4272587299346924,
0.46707168221473694,
0.32365983724594116,
-0.27003198862075806,
1.119806170463562,
0.2779773771762848,
-0.5399728417396545,
-0.5103285312652588,
-0.022142674773931503,
-0.2647562325... |
[Speckle Unity](https://github.com/specklesystems/speckle-unity) is our Unity Connector, it might make it inside Speckle Sharp in the future. | [
-0.8276721835136414,
-0.06208404526114464,
0.7164320349693298,
0.10696426033973694,
-0.3956400156021118,
0.7036747336387634,
0.5050925612449646,
-0.45394936203956604,
0.7101328372955322,
0.012719471007585526,
-0.8152816295623779,
-0.616641104221344,
0.21326394379138947,
-0.3638463020324707... |
Inside our GitHub organisation you'll also find a few additional tools you might want to check out, for example, the two below. | [
-0.4973563253879547,
-0.25443965196609497,
0.4453471004962921,
-0.3170105516910553,
-0.33977606892585754,
0.8258926272392273,
0.34473857283592224,
-0.4796402156352997,
0.7973414063453674,
0.35560569167137146,
-1.0157482624053955,
-0.35301780700683594,
-0.37770214676856995,
0.02507934719324... |
Ever struggle with janky behaviour in Grasshopper as things start getting complicated? You might enjoy the [GrasshopperAsyncComponent](https://speckle.systems/blog/async-gh/).
Do any dev work in Revit and want a handy tool for viewing and running unit tests? [xUnitRevit](https://speckle.systems/blog/xunitrevit/) might be exactly what you've been looking for. | [
-0.43143489956855774,
-0.5909809470176697,
0.2214798778295517,
0.40950241684913635,
-0.248823344707489,
0.09269949793815613,
0.2204330712556839,
-0.3710346519947052,
0.6019734740257263,
0.3100745677947998,
-0.9467877149581909,
-0.18859641253948212,
0.059978414326906204,
-0.0933143272995948... |
Before using any of our software or websites, please make sure you read and understand our [terms of use](https://speckle.systems/terms/), [privacy policy](https://speckle.systems/privacy/) and [trademark usage policy](https://speckle.systems/trademark/).
# Apps and Auth | [
-0.23705586791038513,
-0.1205098032951355,
0.4297409653663635,
0.6704338192939758,
-0.6223507523536682,
0.4834488034248352,
0.230023592710495,
-0.8084079027175903,
0.3835833668708801,
0.6500269770622253,
-0.8265100717544556,
-0.7303676605224609,
-0.45856422185897827,
-0.15780413150787354,
... |
This post was originally part of the Making Speckle 2.0 series of posts on the community forum, it's been adapted as part of our dev docs. Check out [the original on our forum](https://speckle.community/t/apps-authn-speckle-2-0/961)! | [
-0.21245764195919037,
-0.22620835900306702,
0.3856869637966156,
0.4433691203594208,
-0.5746560096740723,
0.2916920483112335,
0.23187707364559174,
-0.6337732076644897,
1.0900800228118896,
0.9016833901405334,
-0.4769405722618103,
-0.4040168821811676,
-0.3998750150203705,
-0.19028949737548828... |
This is a quick post on how authentication with the server works; we've put in _a lot_ of effort to make it easier for developers to extend the functionality of Speckle in their own apps, and simultaneously more secure for end users. | [
-0.6820944547653198,
-0.5025228261947632,
0.617228627204895,
0.19749386608600616,
-0.6302945613861084,
0.4146633744239807,
0.22673605382442474,
-0.806701123714447,
0.8378028273582458,
0.6374492645263672,
-0.4337925314903259,
-0.2342352271080017,
-0.35129180550575256,
0.18352437019348145,
... |
Before we start, we'd like to clarify that this post refers to specifically **authentication**, and not authorization. | [
-0.013901869766414165,
-0.8865162134170532,
0.5035457015037537,
0.4218757152557373,
-0.6768725514411926,
0.3090319037437439,
0.5221922993659973,
-0.5962075591087341,
0.26998093724250793,
0.8835633397102356,
-0.5049214959144592,
-0.06860551983118057,
-0.4817649722099304,
0.3816736042499542,... |
- Authorization (authZ) controls **who has access to what resource**; it's not the focus of this post.
- Authentication (authN) controls **how a user can delegate access to other applications** (pieces of software) that then act on their behalf. | [
-0.19773182272911072,
-0.8753309845924377,
0.1302851289510727,
0.531463623046875,
0.24090877175331116,
0.4367448389530182,
0.37621602416038513,
-0.5875343680381775,
0.4329580068588257,
0.6012110710144043,
-0.6620765924453735,
-0.1056576520204544,
-0.5322054624557495,
0.15775778889656067,
... |
All access to the API is done through bearer tokens that need to present in the Authorization header of each request. There are several ways to create/obtain these tokens, which we'll describe below. First, a few important notes on _tokens in general_: | [
-0.2841089367866516,
-0.6495884656906128,
0.4721778333187103,
0.19823576509952545,
-0.19505304098129272,
0.29132789373397827,
0.7630882859230042,
-0.824790358543396,
0.809810221195221,
1.0953705310821533,
-0.6788426637649536,
-0.26845017075538635,
-0.1432894617319107,
0.39932841062545776,
... |
Each token has a set of associated scopes to it which **limit what actions it can do**. For example, you could have a token that is only allowed to read streams and your profile information. Alternatively, you could have a token that is allowed to search for other users on the server, read your existing streams, create new ones, etc. | [
-0.346731036901474,
-0.6062471270561218,
0.23263631761074066,
0.17781028151512146,
-0.226629838347435,
0.20687052607536316,
0.375738263130188,
-0.6559171676635742,
0.706634521484375,
1.256805658340454,
-0.7886520624160767,
-0.4043179154396057,
-0.7372875809669495,
-0.0808359757065773,
-0... |
As Speckle will grow with functionality, new scopes will be made available. Currently there are: | [
-0.5660690665245056,
0.11336579918861389,
0.5469159483909607,
0.3382132351398468,
-0.29607728123664856,
0.29789385199546814,
0.10447108745574951,
-0.7937250137329102,
0.6760733127593994,
0.9646728038787842,
-0.5888038277626038,
-0.025272030383348465,
-0.7321743369102478,
0.0349190533161163... |
```js
let coreModuleScopes = [
{
name: "server:setup",
description: "Edit server information.",
},
{
name: "tokens:read",
description: `Access your api tokens.`,
},
{
name: "tokens:write",
description: `Create and delete api tokens on your behalf.`,
},
{
name: "streams:read",
description:
"Read your streams & and any associated information (branches, tags, comments, objects, etc.)",
},
{
name: "streams:write",
description:
"Create streams on your behalf and read your streams & any associated information (any associated information (branches, tags, comments, objects, etc.)",
},
{
name: "profile:read",
description: `Read your profile information`,
},
{
name: "profile:email",
description: `Access your email.`,
},
{
name: "users:read",
description: `Read other users' profile on your behalf.`,
},
{
name: "users:email",
description: "Access the emails of other users.",
},
];
``` | [
-0.2692217528820038,
-0.3954019546508789,
0.3710939288139343,
-0.23637250065803528,
-0.29101595282554626,
0.8658300042152405,
-0.09567130357027054,
-0.01738166995346546,
0.8905476927757263,
0.9742802381515503,
-0.8055021166801453,
-0.8119195103645325,
-0.8074393272399902,
-0.21679191291332... |
Tokens also have a certain lifetime after which they're no longer valid. This helps with automatically blocking access to long forgotten apps. Written a little script two years ago that you've totally forgot about, but the token's nicely pasted in the codebase since you've never published it? Well, now that's safe even if someone else somehow snitches it - it probably expired. | [
0.0034719810355454683,
-0.426910400390625,
0.5872001647949219,
0.34633225202560425,
-0.13050022721290588,
0.4256480038166046,
0.5091592669487,
-0.5556385517120361,
0.29971063137054443,
0.7473337054252625,
-0.40034785866737366,
-0.46770304441452026,
-0.4593425691127777,
-0.13517840206623077... |
As a developer, you can now create personal access tokens that you can use to delegate access to your script on your behalf, similar to how Github's [Personal Access Tokens](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token) work. | [
-0.1971324384212494,
-0.1653730422258377,
0.24342621862888336,
0.2757933437824249,
0.1585281491279602,
0.8939756155014038,
0.1279679238796234,
0.14293938875198364,
1.0841574668884277,
0.8631604909896851,
-0.512744128704071,
-0.6684575080871582,
-0.35695216059684753,
0.1788027286529541,
-... |
When you create them, you can assign assign to them whatever scopes & lifetime you want to, just remember to limit both to the minimum to be _safe._ | [
-0.2630961835384369,
-0.11357685178518295,
0.4168018102645874,
0.41804957389831543,
-0.19612900912761688,
-0.1638890951871872,
0.2954121232032776,
-0.6086297035217285,
-0.1565086543560028,
0.8073714375495911,
-0.682894766330719,
-0.014221476390957832,
-0.6229793429374695,
-0.05788989737629... |
Once you're beyond the hacking phase, you'll probably want to create & publish a speckle app that others can use. As a developer, you can: | [
-0.6622437834739685,
-0.20264434814453125,
0.4484058916568756,
0.8147568702697754,
-0.3035481870174408,
0.4595821797847748,
0.2226869761943817,
-0.9051911234855652,
1.0088616609573364,
0.8353920578956604,
-0.4937705397605896,
-0.26590001583099365,
-0.6213566064834595,
-0.3813256025314331,
... |
- register apps that others can use (or not),
- manage the apps you have created - edit name, description, redirect url, scopes, and delete. | [
-0.9295966029167175,
-0.09653376787900925,
0.3677251636981964,
0.28016555309295654,
0.31641483306884766,
0.13061967492103577,
0.04233505204319954,
-0.24610641598701477,
0.6204416751861572,
0.9588683247566223,
-0.6478053331375122,
-0.652294397354126,
-0.06315790861845016,
0.0644269660115242... |
Once an app is registered on a server, users can now delegate access to it for the set of scopes that the developer registered for that application. Once the delegation process is successful - the user approves it - they will get redirected to the url that the developer specified. | [
-0.789071798324585,
-0.13792355358600616,
0.4041757583618164,
0.5377376675605774,
0.1501009613275528,
0.22181794047355652,
0.08567798137664795,
-0.35338714718818665,
0.36684906482696533,
1.1778557300567627,
-0.7343652844429016,
-0.30780404806137085,
-0.30635368824005127,
0.0429589711129665... |
Of course, as an end user, you have full control and visibility on the apps you have authorized. You can: | [
-0.1941526085138321,
-0.3067706823348999,
0.48077309131622314,
0.39398783445358276,
0.034920476377010345,
0.3649766743183136,
0.19245144724845886,
-0.931747317314148,
0.3436211347579956,
1.1643664836883545,
-0.3207198679447174,
-0.4712977707386017,
-0.672188401222229,
-0.07258553057909012,... |
- see all your authorized apps (apps that you have granted access to),
- revoke access to any of the above,
- check out any publicly listed apps on this server (optional at this stage) | [
-0.5149163603782654,
-0.4696579873561859,
0.29097774624824524,
0.24740038812160492,
-0.05439485237002373,
0.6594682335853577,
0.47732222080230713,
-0.3950774371623993,
0.7623414397239685,
1.7628551721572876,
-1.095436453819275,
-0.6432172060012817,
-0.46695220470428467,
0.14306916296482086... |
- Apps that act on behalf of a user - **supported ✅**
- Apps that can act with their own identity - **not currently supported ⏱** | [
-0.06253410875797272,
0.011707203462719917,
0.4769357442855835,
1.006291389465332,
-0.09466084837913513,
0.508173942565918,
0.5789657235145569,
-0.5447481274604797,
0.809104859828949,
1.251217007637024,
-0.6781495213508606,
-0.32830673456192017,
-0.35128089785575867,
0.16524048149585724,
... |
We'll write soon more documentation on how the authentication flow with the Server actually works. For the geeks out there, here's a short summary, or some important points: | [
-0.6396223902702332,
-0.860491931438446,
0.7953264713287354,
-0.3601866066455841,
-0.24407115578651428,
0.07072773575782776,
0.18686209619045258,
-0.764258086681366,
0.5088462829589844,
0.687638521194458,
-0.5489699244499207,
-0.27292394638061523,
-0.021980421617627144,
-0.1231156885623931... |
- We are supporting the **authorization_code** flow with **PKCE** only for public and confidential clients.
- We do not support dynamic scope requests for apps. We **only support pre-registered scopes for each app**.
- If an app is edited in any way - name, scopes, etc. - all its tokens get revoked and users will need to re-authorize it. | [
-0.2205202728509903,
-0.2258889526128769,
0.48088765144348145,
0.6036587357521057,
-0.07828297466039658,
0.3503631055355072,
0.11398263275623322,
-0.514253556728363,
0.3928576707839966,
0.9685531258583069,
-0.5992234349250793,
-0.7101243734359741,
-0.4432479739189148,
0.08533623814582825,
... |
Clients are usually split into two categories: public and private. Public clients cannot realistically hold a secret, whereas private ones can. For example, a front-end only web application is a public client; same goes for the desktop connectors. A private client can be a server-side application, which can realistically store an application secret in, for example, a .env file or provide it during the CI/CD process. | [
-0.555659294128418,
-0.5866415500640869,
0.3492673635482788,
0.4999016225337982,
0.08090967684984207,
0.37018051743507385,
-0.10311514884233475,
-0.6631747484207153,
0.2262275665998459,
0.6983528137207031,
-0.4389713704586029,
-0.5470190048217773,
-0.01562744379043579,
0.0812351256608963,
... |
- Using exclusively a pre-registered redirect URL.
- Native apps (desktop): registering a custom application scheme (`speckle://`).
- PKCE (Proof of Key For Code Exchange).
- a client id & client secret, but the clientSecret is superfluous in the case of public clients. | [
-0.5574812889099121,
-0.313029408454895,
0.20075109601020813,
0.418691486120224,
-0.21045267581939697,
0.3689974844455719,
0.06017579138278961,
-0.3156655430793762,
0.6675847768783569,
0.8794299960136414,
-0.5288220047950745,
-1.0419842004776,
0.28759193420410156,
-0.11069513112306595,
-... |
The 2.0 server already comes with two applications that demonstrate this flow (warning - there might still be bugs). These are: | [
-0.29194527864456177,
-0.5625888705253601,
0.610266387462616,
0.5602277517318726,
-0.27629056572914124,
0.11699255555868149,
0.2812754213809967,
-0.9275013208389282,
0.39446157217025757,
0.9872639179229736,
-0.9236844778060913,
-0.11997439712285995,
-0.2557661831378937,
-0.5844468474388123... |
- The main web frontend application - accessible at the server's default url, and
- The GraphQL explorer - accessible at your server's url + `/explorer`. | [
-0.9169785380363464,
-0.7244808673858643,
0.2570987939834595,
0.04970956966280937,
-0.018010158091783524,
0.6331340074539185,
0.43009912967681885,
-0.4211731553077698,
0.49502062797546387,
1.083621859550476,
-1.0371216535568237,
-0.9350259900093079,
0.1428067982196808,
0.47969481348991394,... |
We've put a lot of work into making Speckle developer friendly and extensible - and apps are just a small part of that. We hope that writing Speckle Apps will be fun and effective, and we can't wait to see what you'll do with them!
# Creating Your Own App | [
-0.5398346185684204,
-0.14998550713062286,
0.3086989223957062,
0.7493144273757935,
-0.29170119762420654,
0.30432188510894775,
0.015439862385392189,
-0.852240800857544,
0.8779924511909485,
0.5598496198654175,
-0.42808273434638977,
-0.4499819278717041,
-0.12987811863422394,
-0.29304590821266... |
Welcome to this guide on how to `Create your own App` using Speckle. It's geared towards an audience that is familiar with Javascript and web development, or at least not scared by it! | [
-0.7064918279647827,
-0.21325422823429108,
0.21224083006381989,
0.7258935570716858,
-0.17143560945987701,
0.3780193626880646,
0.2546597123146057,
-0.4288886785507202,
0.8377603888511658,
0.649849534034729,
-0.4487192928791046,
-0.7424394488334656,
-0.0637679398059845,
-0.28235724568367004,... |
In this example, we'll be creating a very simple web app capable of: | [
-0.23051033914089203,
-0.45285025238990784,
0.3174927234649658,
0.6768901348114014,
-0.3396078646183014,
-0.40012890100479126,
0.4896646738052368,
-0.32276445627212524,
0.2696112096309662,
0.5946416258811951,
-0.8202323317527771,
-0.34484803676605225,
0.25655582547187805,
-0.00000583184373... |
- Authenticating a user through a Speckle server OAuth.
- Search for stream's available to the user.
- Display commit data associated with a given stream.
- Filter the data to be displayed.
- Cache results in `localStorage` to _remember_ the app state across page reloads. | [
-0.5850674510002136,
-0.2756049931049347,
0.45409247279167175,
-0.1792653501033783,
-0.18688595294952393,
0.4554866850376129,
0.26639971137046814,
-0.23783332109451294,
0.9755390286445618,
0.7826180458068848,
-0.35595741868019104,
-0.4950810372829437,
0.011529514566063881,
-0.0596587061882... |
If too busy to follow all the steps, you can find the entire code for this guide [in this repository](https://github.com/specklesystems/speckle-demo-app). | [
-0.39419257640838623,
-0.26130422949790955,
1.0098761320114136,
0.7173376083374023,
-0.6915343403816223,
-0.014131384901702404,
0.16887517273426056,
-0.029792776331305504,
0.7335812449455261,
0.9147290587425232,
-0.8603794574737549,
-0.39227113127708435,
-0.26462092995643616,
-0.2589153945... |
This guide should work in any platform (Mac/Linux/Windows). We'll be using _VSCode_ as our IDE but you can use any other (even Notepad if your brave enough!). | [
-0.36386388540267944,
-0.6404078006744385,
0.7234100103378296,
0.5480201244354248,
-0.5040736198425293,
0.028836742043495178,
-0.04384927451610565,
-0.19925740361213684,
0.6214438676834106,
0.4632733166217804,
-0.4006749093532562,
-1.3508658409118652,
-0.3086824119091034,
0.280831307172775... |
You'll also need to have Node installed, as well as `vue-cli` and have some basic understanding of how Vue works. | [
-0.5366662740707397,
-0.6219802498817444,
0.587805449962616,
-0.2840971052646637,
-0.4103696346282959,
0.5856149792671204,
0.3267935514450073,
-0.33825868368148804,
0.5248150825500488,
0.6347552537918091,
-0.693552553653717,
-0.5668129324913025,
-0.8329163193702698,
-0.22993166744709015,
... |
**Node:** Probably the easiest way to manage your node installation is through `nvm`. On Windows, you can [use this guide](https://github.com/coreybutler/nvm-windows#install-nvm-windows). If on OSX, you can use the [original nvm](https://github.com/nvm-sh/nvm#installing-and-updating). | [
-0.5766434073448181,
-0.46786975860595703,
0.8115054965019226,
0.08541060239076614,
-0.488986998796463,
0.671174943447113,
0.2202335149049759,
-0.006918524391949177,
0.4627082645893097,
0.7609706521034241,
-0.5646212697029114,
-0.7600990533828735,
-0.3827548027038574,
0.10661476850509644,
... |
**Vue CLI**: Once you have node installed, it's just a matter of running `npm install -g @vue/cli`. | [
-0.41859009861946106,
-0.5453650951385498,
0.731938362121582,
-0.1680973768234253,
-0.4525242745876312,
0.7810681462287903,
0.16843020915985107,
0.0389263816177845,
0.7509825825691223,
0.9326621890068054,
-0.7424833178520203,
-0.770718514919281,
-0.7568703889846802,
-0.02906324528157711,
... |
If you haven't used Vue before, don't worry. It's quite easy to get started with it - here's [some docs](https://vuejs.org/v2/guide/) you could run through beforehand. | [
-0.4260379374027252,
-0.5703667998313904,
0.824177086353302,
-0.07165206223726273,
-0.5940428376197815,
-0.14352355897426605,
0.2238718718290329,
-0.37180301547050476,
0.5331602096557617,
0.23260340094566345,
-0.6747753620147705,
-0.7806876301765442,
-0.4626435935497284,
-0.240379825234413... |
We'll also be using some of Vue's most popular plugins: `vuex` and `vue-router`. If you're unfamiliar with them, they have great quick-start guides on their site! | [
-0.6190957427024841,
-0.29950737953186035,
0.4399273097515106,
0.03715943917632103,
-0.44870948791503906,
0.21381662786006927,
0.39521631598472595,
-0.11373284459114075,
0.33632004261016846,
0.49844732880592346,
-0.38348743319511414,
-0.6919834613800049,
-0.043711017817258835,
-0.057209420... |
This is the simplest step. Open a new terminal, set the current directory to wherever you want the project to be located and run the following command: | [
-0.6657738089561462,
-0.27566811442375183,
0.7203558683395386,
-0.06660270690917969,
-0.24188756942749023,
0.9691588282585144,
0.21087278425693512,
0.2730962634086609,
0.8392084240913391,
0.741619884967804,
-0.43378686904907227,
-0.6748039126396179,
-0.6618649959564209,
0.02127539366483688... |
This will ask you some questions, such as the version of vue to use, what plugins to install, etc. **It is important that you answer the questions correctly**, otherwise, your project may be missing some key features. | [
-1.0928391218185425,
-0.9217383861541748,
0.4210500717163086,
0.18760627508163452,
-0.17289194464683533,
-0.008705589920282364,
0.6421037316322327,
-0.5444614887237549,
0.4651039242744446,
0.7417765855789185,
-1.0156135559082031,
-0.20773187279701233,
-0.42747798562049866,
-0.0692716762423... |
1. When prompted for a preset, select **Manually select features**

2. Next, specify the features needed for this project:
- Choose vue version
- Babel
- PWA
- Router
- Vuex
- CSS Pre-processors
- Linter

3. Choose version **2.x** of Vue.js

4. Choose **Yes** when prompted to use **history mode for router**

5. For the css-preprocessor to use, select **Sass/SCSS (with dart-sass)**

6. When prompted for a Linter, choose the option **ESLint with error prevention only**

7. When prompted for additional lint features, select **Lint on save**

8. Choose to place config files **In dedicated config files**

9. At last, you can save this selection as a preset, but for this time just select **No**

10. Wait for the process to finish
 | [
-1.014509677886963,
-0.08757128566503525,
0.28048330545425415,
0.12160733342170715,
-0.3204280138015747,
0.10898968577384949,
0.17135004699230194,
0.08742709457874298,
0.4768570363521576,
0.9625552892684937,
-0.8267017006874084,
-0.4234427809715271,
-0.3654889464378357,
-0.1305048167705536... |
If you are already familiar with this process, just select the same answers as the screenshot bellow: | [
-0.9519674181938171,
-0.667472243309021,
0.7586621642112732,
-0.09081164747476578,
-0.5914191603660583,
0.3061272203922272,
0.2528401017189026,
-0.4065629839897156,
0.5757305026054382,
1.2503303289413452,
-1.2225062847137451,
0.06388920545578003,
-0.4897650480270386,
0.11959328502416611,
... |
:::
Once done, you'd have your Vue project ready. To open the project in **VSCode** we just need to run: | [
-0.3241238296031952,
0.12877170741558075,
0.3451088070869446,
0.04428442567586899,
-0.4634648561477661,
0.5045796036720276,
0.11140843480825424,
0.10184802860021591,
0.6284489631652832,
0.9197461605072021,
-0.5656314492225647,
-0.6240314841270447,
-0.5722584128379822,
-0.1690114289522171,
... |
This step assumes you already installed VSCode in your path. If you haven't, there's a command for it in VSCode. | [
-0.574378490447998,
-0.17493878304958344,
0.5945276021957397,
0.3190731704235077,
-0.5203377604484558,
0.7393401265144348,
0.19666917622089386,
0.15233929455280304,
0.7949357628822327,
0.920233428478241,
-1.1441054344177246,
-0.76181960105896,
-0.9996913075447083,
0.014885746873915195,
-... |
For our UI, we'll also be using [Vuetify](TODO) to make our life easier, as it has many useful components. To add it, run: | [
-0.5382927656173706,
-0.3602963984012604,
0.3609911799430847,
0.1938457041978836,
-0.7352141737937927,
-0.10521350800991058,
0.11396844685077667,
0.2239469587802887,
0.28204941749572754,
0.8421949148178101,
-0.8274337649345398,
-0.3894312083721161,
-0.15320655703544617,
-0.0423920638859272... |
We'll also need to add a couple of handy dependencies such as `vuex-persist` for state storage, `vue2-timeago` to display user-friendly dates and `debounce`. For this, run the following command: | [
-0.35921531915664673,
-0.2525250315666199,
0.5244948267936707,
0.3610284626483917,
-0.3924841582775116,
-0.03000185824930668,
0.4588983654975891,
-0.1117490902543068,
0.6844474077224731,
0.42503565549850464,
-0.55705326795578,
-0.4649009108543396,
-0.21613378822803497,
-0.27431729435920715... |
If everything went well, running the following command should make the app available at [http://localhost:8080](http://localhost:8080). | [
-0.6464665532112122,
-0.2427375465631485,
0.5891283750534058,
0.7601096034049988,
-0.5013461709022522,
0.3001236319541931,
-0.1712481826543808,
0.11757875978946686,
0.8713343739509583,
0.9416596293449402,
-0.36601147055625916,
-0.31233087182044983,
-0.5163087248802185,
0.2588638663291931,
... |
For convenience, we're going to isolate all the `speckle` related code into 2 files: | [
-0.4748101532459259,
-0.3965230882167816,
0.4469081163406372,
0.5807722210884094,
-0.8684371709823608,
-0.06791161745786667,
0.0862414762377739,
-0.4931538701057434,
0.42041194438934326,
0.8780286312103271,
-0.35986098647117615,
-0.3231249749660492,
-0.40673592686653137,
-0.081017248332500... |
- `src/speckleQueries.js` will hold some utility functions to build our `GraphQL` queries.
- `src/speckleUtils.js` will hold all call's to the Speckle server, as well as some constants. It will deal with login/logout functionality too. | [
-0.6602335572242737,
-0.5479018092155457,
0.2358255833387375,
0.013031722977757454,
-0.20503389835357666,
0.856848955154419,
0.3786497414112091,
-0.3217929005622864,
0.8074198961257935,
0.7715311050415039,
-0.7140944600105286,
-0.5859314203262329,
0.00534133892506361,
-0.08430945873260498,... |
In order to be able to talk to our Speckle server, we first need to `Create an App` in that server with an existing account. To do that, visit the server's frontend [https://app.speckle.systems](https://app.speckle.systems), log in with your account and visit the profile page. | [
-0.8470290899276733,
0.04455127567052841,
0.38195788860321045,
0.2897672951221466,
-0.2929914593696594,
0.8121721148490906,
0.23566535115242004,
-0.703737199306488,
1.0759530067443848,
0.6538825035095215,
-0.8240477442741394,
-0.3122483789920807,
-0.3565303087234497,
0.041303858160972595,
... |
Scroll down until you see the `Applications` section, and press the `New App` button. A pop-up should appear, fill it in as follows: | [
-0.8687041401863098,
-0.22362297773361206,
0.6284170150756836,
0.572333574295044,
0.06793147325515747,
0.8493896126747131,
0.5498465299606323,
-0.010863215662539005,
1.0454037189483643,
0.8352230191230774,
-0.9488738775253296,
-0.5946199297904968,
-0.4246159791946411,
-0.11014539003372192,... |
- **Name:** SpeckleDemoApp
- **Scopes**: `stream:read`, `profile:read`, `profile:email`
- **Redirect url**: `http://localhost:8080`
- **Description**: My first speckle app | [
-0.6186408996582031,
-0.2850686013698578,
0.14963136613368988,
0.3061772286891937,
-0.6345781087875366,
0.5192338824272156,
0.037867411971092224,
-0.1416105329990387,
1.3284190893173218,
0.9801393747329712,
-0.9252490401268005,
-0.7098799347877502,
-0.8437573313713074,
-0.14604023098945618... |
Once accepted, you'll see the `App Id` and `App Secret`, as well as an indication to the url pattern we should use (`https://app.speckle.systems/authn/verify/{appId}/{challenge}`). | [
-0.5430796146392822,
-0.12414590269327164,
0.4328385591506958,
0.27575036883354187,
-0.3182280361652374,
0.4576621353626251,
0.3495553433895111,
-0.3772984445095062,
0.5202353596687317,
0.4937218129634857,
-0.8801143765449524,
-0.7457036972045898,
-0.44076594710350037,
0.1269284188747406,
... |
::: warning
Note that the `redirect url` points to our local computer network. When deploying this app to a service like Netlify, we'll have to create a new one pointing to the correct Netlify url.
::: | [
-0.5132782459259033,
-0.4500875473022461,
-0.2550446689128876,
0.730128824710846,
-0.3386889100074768,
-0.10258761048316956,
0.26436352729797363,
-0.27960750460624695,
0.4964401423931122,
1.0751579999923706,
-0.9716459512710571,
-0.3547019362449646,
-0.2770706117153168,
0.5007032155990601,... |
The `App Id` and `App Secret` are used to identify your app, so you should never add them to your version control. Instead, we'll be using `ENV` variables to save that information, which also allows us to modify it in different scenarios (development/production). | [
-0.6672322750091553,
-0.30680519342422485,
-0.11992298811674118,
0.053676024079322815,
-0.39281997084617615,
0.29282063245773315,
0.3519814610481262,
-0.09865110367536545,
0.23937785625457764,
0.5365341901779175,
-0.6361187100410461,
-0.6675654053688049,
0.14650069177150726,
0.004762708209... |
For those of you who wonder, frontend applications that integrate with the Speckle Server are treated as OAuth **public applications**, because they cannot keep their id and secret safe. | [
-0.5896636247634888,
-0.2085711807012558,
0.5258305072784424,
0.2715638279914856,
-0.26910439133644104,
0.36551064252853394,
0.2995603084564209,
-0.8518765568733215,
0.42656004428863525,
1.043632984161377,
-0.47271519899368286,
-0.7849942445755005,
-0.2586599588394165,
0.004021171946078539... |
Vue will automatically read any `.env` files in the root of your project and load the variables accordingly, but will also replace all references with the actual value of the variable on compilation (which we **do not want**). We can tell `vue.js` to not do this by creating a file named `.env.local` instead. The contents should look like this 👇🏼 (remember to replace your ID and Secret appropriately). | [
-0.28692835569381714,
-0.4268649220466614,
0.2928682863712311,
-0.5054959058761597,
-0.36985671520233154,
0.2167263925075531,
0.11927013099193573,
-0.4582059383392334,
0.2918183207511902,
1.047715663909912,
-0.6269093155860901,
-0.5656173229217529,
-0.2234078347682953,
0.05576053634285927,... |
A simplified version of the auth flow with a Speckle Server can be summarised as follows: | [
-0.05850786715745926,
-0.0290436539798975,
0.24165624380111694,
0.12705250084400177,
-0.8451720476150513,
0.11790265142917633,
0.49681639671325684,
-0.44761765003204346,
0.8812571167945862,
1.129698395729065,
-0.7758236527442932,
-0.2084672749042511,
-0.28845617175102234,
0.060083676129579... |
1. User clicks the Login button
2. User is redirected to the auth page in the Speckle server (using the provided url pattern when creating an application)
3. User will log in and allow the app to access their data (hopefully?).
4. User is redirected to our specified `Redirect URL`, with an attached `access_code`.
5. Using that access code, we can exchange it for a pair of `token/refresh token`, which is what allows the app to "talk" to the server as that user. We'll save those in `localStorage`. | [
-0.490222692489624,
-0.3429533541202545,
0.35805419087409973,
0.1623838245868683,
-0.17889678478240967,
0.3841307759284973,
0.32755163311958313,
-0.4828667640686035,
0.5585588812828064,
0.9154990911483765,
-0.5204204320907593,
-0.495617538690567,
0.16392222046852112,
0.16954925656318665,
... |
This may sound rather complicated, but it boils down to 2 different interactions (redirect your user and exchange the access code). | [
-0.15274614095687866,
-0.7168105840682983,
0.4426325559616089,
0.4918978810310364,
-0.10732980817556381,
-0.10464657843112946,
0.2661445438861847,
-0.7802395224571228,
0.43189096450805664,
0.6194716691970825,
-0.9352723360061646,
0.0769159346818924,
-0.24741500616073608,
0.1409558951854705... |
In our `src/speckleUtils.js` file, paste in the following code. You'll find some constants that refer to our previously set `ENV` variables, as well as several functions. | [
-0.4652456045150757,
0.07974603772163391,
0.30968454480171204,
0.027076086029410362,
-0.1807546764612198,
0.5362190008163452,
-0.06524108350276947,
-0.2823839783668518,
0.7007748484611511,
0.914426326751709,
-0.6814072132110596,
-0.4527084231376648,
-0.17949801683425903,
0.1650847941637039... |
- `goToSpeckleAuthPage`: Will generate a random challenge, save it in localStorage and direct the url to the auth page in the specified speckle server.
- `exchangeAccessCode`: Will `fetch` from the server a new pair of `token/refresh token` and clear the `challenge`.
- `speckleLogOut`: Will erase all necessary data from `localStorage`. | [
-0.47007468342781067,
-0.5235399603843689,
0.2978127598762512,
0.008507977239787579,
-0.4072984755039215,
0.5571393370628357,
0.08567676693201065,
-0.348385214805603,
1.0004559755325317,
0.924495279788971,
-0.6284708976745605,
-0.46414312720298767,
-0.12415597587823868,
0.07994664460420609... |
::: tip
Note that `goToSpeckleAuthPage` saves the challenge, and `exchangeAccessCode` uses that same challenge to exchange the tokens. If the challenge used doesn't match, the request will fail.
::: | [
-0.11328060925006866,
-0.26282593607902527,
0.37861019372940063,
0.531627357006073,
-0.2303469181060791,
0.24495829641819,
0.23077623546123505,
-0.19846124947071075,
0.9830088019371033,
0.6712461709976196,
-0.7227190732955933,
-0.2808765470981598,
-0.47439923882484436,
0.10246653854846954,... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.